/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Sentinel::check()) {
         //            dump('未登陆');
         //未登陆,跳转到登陆页面
         return redirect()->route('account_login_get');
     }
     //        dump('已登陆');
     return $next($request);
 }
 /**
  * 返回上次访问页面
  *
  * 无法获取上次访问页面时,已登陆,返回数据首页;未登陆,返回登陆页;
  *
  * @return string
  */
 public function pre_web_page_url()
 {
     if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != null) {
         $pre_url = $_SERVER['HTTP_REFERER'];
         return $pre_url;
     }
     if (Sentinel::check()) {
         $pre_url = route('data_index');
     } else {
         $pre_url = route('account_login_get');
     }
     return $pre_url;
 }
Exemplo n.º 3
2
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Sentinel::check()) {
         return redirect('/home');
     }
     return $next($request);
 }
Exemplo n.º 4
2
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Sentinel::check()) {
         return redirect()->action('UserController@getSignin');
     }
     return $next($request);
 }
Exemplo n.º 5
2
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (!Sentinel::check()) {
         abort(401);
     }
     return View::make('customer.welcome');
 }
Exemplo n.º 6
2
 public function getLogout()
 {
     if (Sentinel::check()) {
         $this->authRepository->logout();
         Flash::success('Log out successfully!');
         return Redirect::route('getAuth');
     }
     return Redirect::route('getAuth');
 }
Exemplo n.º 7
2
 /**
  * Redirects unauthenticated users to the login page.
  *
  * @param Request $request
  * @param Closure $next
  *
  * @return Request|\Illuminate\Http\RedirectResponse
  */
 public function handle(Request $request, Closure $next)
 {
     if (Sentinel::check()) {
         return $next($request);
     } else {
         $message = "You're not logged in.";
         return redirect()->route('maintenance.login')->withErrors($message);
     }
 }
Exemplo n.º 8
1
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Sentinel::check() && !Sentinel::hasAccess('admin')) {
         return Redirect::to('login')->withErrors(['Only admins can access this page.']);
     }
     return $next($request);
 }
Exemplo n.º 9
0
 /**
  * Boot the creation trait for a model.
  *
  * @return void
  */
 public static function bootCreation()
 {
     // create a event to happen on deleting
     static::deleting(function ($table) {
         if (class_exists('Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
             $table->deleted_by = Sentinel::getUser()->id;
         } else {
             $table->deleted_by = Auth::user()->id;
         }
         $table->update(['deleted_by' => $table->deleted_by]);
     });
     // create a event to happen on saving
     static::saving(function ($table) {
         if (class_exists('Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
             if (Sentinel::check()) {
                 $table->modified_by = Sentinel::getUser()->id;
             }
             if (Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) {
                 $table->created_by = Sentinel::getUser()->id;
             }
         } else {
             if (!Auth::guest()) {
                 $table->modified_by = Auth::user()->id;
             }
             if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) {
                 $table->created_by = Auth::user()->id;
             }
         }
     });
 }
Exemplo n.º 10
0
 /**
  * Get the ID for the currently authenticated user.
  *
  * @return int|null
  */
 public function id()
 {
     if ($user = Sentinel::check()) {
         return $user->id;
     }
     return null;
 }
 /**
  * @param $request
  * @param Closure $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Sentinel::check()) {
         throw new AccessDeniedHttpException(trans('auth.errors.invalid_permission'));
     }
     return $next($request);
 }
Exemplo n.º 12
0
 public function __construct()
 {
     $this->page = new \stdClass();
     // Заголовок страницы
     $this->page->title = '';
     // Описание страницы
     $this->page->desc = '';
     $this->page->base_url = 'http://' . request()->server('HTTP_HOST') . '/';
     // Данные пользователя
     if (!Sentinel::check()) {
         $this->user = false;
     } else {
         $this->user = Sentinel::getUser();
     }
 }
Exemplo n.º 13
0
 public function doLogin(Requests\UserValidateRequest $request)
 {
     if ($user = Sentinel::check()) {
         return redirect('/');
     } else {
         $input = $request->all();
         $credentials = ['email' => $input['email'], 'password' => $input['password']];
         $user = Sentinel::authenticate($credentials);
         if (!$user) {
             return redirect('login')->withErrors('Your e-mail or your password is incorrect');
         } else {
             Sentinel::authenticate($credentials);
             return redirect('/');
         }
     }
 }
Exemplo n.º 14
0
 /**
  * {@inheritDoc}
  */
 public function check()
 {
     return Sentinel::check();
 }
Exemplo n.º 15
0
 /**
  * Updates the session of the current user.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $query
  * @return \Illuminate\Database\Eloquent\Builder
  */
 public function scopeUpdateCurrent(Builder $query)
 {
     $user = Sentinel::check();
     return $query->where('id', Session::getId())->update(['user_id' => $user ? $user->id : null]);
 }
Exemplo n.º 16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if (Sentinel::check()->id != $id) {
         $user = User::find($id);
         $user->delete();
         Toastr::success("The account has been removed");
         return redirect(action("Admin\\UsersController@index"));
     } else {
         Toastr::error("You cannot remove your own account");
         return back();
     }
 }
Exemplo n.º 17
0
 public static function getLoggedUserID()
 {
     $user = Sentinel::check();
     return $user->id;
 }
Exemplo n.º 18
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     if ($user = Sentinel::check()) {
         Course::find($id)->delete();
         return redirect('admin');
     } else {
         return redirect('/');
     }
 }
Exemplo n.º 19
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return Sentinel::check();
 }