当前位置: 首页>>代码示例>>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;未经允许,请勿转载。