當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Guard::guest方法代碼示例

本文整理匯總了PHP中Illuminate\Auth\Guard::guest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Guard::guest方法的具體用法?PHP Guard::guest怎麽用?PHP Guard::guest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Auth\Guard的用法示例。


在下文中一共展示了Guard::guest方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         return redirect()->guest('/');
     }
     if (Auth::user()->role === 'admin' || Auth::user()->role === 'superadmin') {
         return $next($request);
     }
     return redirect()->guest('/');
 }
開發者ID:orsic,項目名稱:bushido,代碼行數:17,代碼來源:AdminMiddleware.php

示例2: handle

 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         return redirect()->guest('login');
     }
     if ($this->auth->check() && !$this->auth->user()->isAdmin()) {
         App::abort('403');
     }
     return $next($request);
 }
開發者ID:studiocaro,項目名稱:HorseStories,代碼行數:10,代碼來源:Admin.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->admin->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('connexion');
         }
     }
     return $next($request);
 }
開發者ID:abasslassdoss,項目名稱:oussama,代碼行數:18,代碼來源:AppMiddleware.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $action = $request->route()->getAction();
     if ($this->auth->guest() || !$this->auth->user()->can($action['permission'])) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->route('admin.login');
         }
     }
     return $next($request);
 }
開發者ID:cinject,項目名稱:admin-panel,代碼行數:19,代碼來源:Permission.php

示例5: index

 public function index(Guard $guard)
 {
     if (!$guard->guest()) {
         return redirect(route('app.dashboard.index'));
     }
     return view('layouts.login.index');
 }
開發者ID:andersonef,項目名稱:RestoApp,代碼行數:7,代碼來源:AuthController.php

示例6: logout

 /**
  * Logout the active user.
  *
  * @param UserAuthenticator $authenticator
  * @param Guard             $auth
  * @return \Illuminate\Http\RedirectResponse
  */
 public function logout(UserAuthenticator $authenticator, Guard $auth)
 {
     if (!$auth->guest()) {
         $authenticator->logout();
     }
     $this->messages->success($this->request->get('message', 'anomaly.module.users::message.logged_out'));
     return $this->response->redirectTo($this->request->get('redirect', '/'));
 }
開發者ID:jacksun101,項目名稱:users-module,代碼行數:15,代碼來源:LoginController.php

示例7: logout

 /**
  * Log the user out.
  *
  * @param UserAuthenticator $authenticator
  * @param Guard             $auth
  * @return \Illuminate\Http\RedirectResponse|Redirector
  */
 public function logout(UserAuthenticator $authenticator, Guard $auth)
 {
     if (!$auth->guest()) {
         $authenticator->logout();
     }
     $this->messages->success('anomaly.module.users::message.logged_out');
     return redirect('admin/login');
 }
開發者ID:AkibaTech,項目名稱:users-module,代碼行數:15,代碼來源:LoginController.php

示例8: handle

 public function handle($request, Closure $next, $role)
 {
     if ($this->auth->guest()) {
         //未登入
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->route('user.login');
         }
     } elseif (!$this->checkRoleInheritance(Auth::user(), $role)) {
         //權限不足
         return redirect()->route('home')->with('warning', '權限不足');
     } elseif (empty($this->auth->user()->confirm_at)) {
         //未驗證信箱
         return redirect()->route('user.resend')->with('warning', '完成信箱驗證方可進入此頁麵');
     }
     return $next($request);
 }
開發者ID:alhs1995,項目名稱:DBFP,代碼行數:18,代碼來源:RoleLimit.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @param $role
  * @return mixed
  */
 public function handle($request, Closure $next, $permissionName)
 {
     if ($this->auth->guest()) {
         //未登入
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->route('member.login');
         }
     }
     $user = $this->auth->user();
     if (empty($user->confirm_at)) {
         //未驗證信箱
         return redirect()->route('member.resend')->with('warning', '完成信箱驗證方可進入此頁麵');
     }
     //取得權限
     $permission = Permission::where('name', '=', $permissionName)->first();
     if (!$permission || !$user->can($permissionName)) {
         return redirect()->route('home')->with('warning', '權限不足');
     }
     return $next($request);
 }
開發者ID:alhs1995,項目名稱:DBFP,代碼行數:30,代碼來源:PermissionCheck.php

示例10: guest

 /**
  * Determine if the current user is a guest.
  *
  * @return bool 
  * @static 
  */
 public static function guest()
 {
     return \Illuminate\Auth\Guard::guest();
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:10,代碼來源:_ide_helper.php

示例11: filter

 public function filter(Route $route, Request $request)
 {
     if ($this->auth->guest()) {
         return $this->makeResponse($request);
     }
 }
開發者ID:anlutro,項目名稱:l4-core,代碼行數:6,代碼來源:AuthFilter.php


注:本文中的Illuminate\Auth\Guard::guest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。