当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth\Guard类代码示例

本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard的典型用法代码示例。如果您正苦于以下问题:PHP Guard类的具体用法?PHP Guard怎么用?PHP Guard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Guard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(UsersRepo $usersRepo, Guard $guard)
 {
     $this->usersRepo = $usersRepo;
     $this->current_user = $guard->user();
     $this->middleware('CMSAuthenticate');
     view()->share('user_types', getUserTypesList());
 }
开发者ID:rubenalternative,项目名称:simple-cms,代码行数:7,代码来源:UserController.php

示例2: postLogin

 /**
  * Handle a login request to the application.
  *
  * @param  App\Http\Requests\LoginRequest  $request
  * @param  App\Services\MaxValueDelay  $maxValueDelay
  * @param  Guard  $auth
  * @return Response
  */
 public function postLogin(LoginRequest $request, Guard $auth)
 {
     $logValue = $request->input('log');
     $logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
     }
     $credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
     if (!$auth->validate($credentials)) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
     }
     $user = $auth->getLastAttempted();
     if ($user->confirmed) {
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         $auth->login($user, $request->has('memory'));
         if ($request->session()->has('user_id')) {
             $request->session()->forget('user_id');
         }
         return redirect('/');
     }
     $request->session()->put('user_id', $user->id);
     return redirect('/auth/login')->with('error', trans('front/verify.again'));
 }
开发者ID:thaida,项目名称:CMS,代码行数:37,代码来源:AuthController.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->auth->check()) {
         return redirect('SiteController@index');
     }
     return $next($request);
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:14,代码来源:RedirectIfAuthenticated.php

示例4: 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()) {
         throw new HttpException(401);
     }
     return $next($request);
 }
开发者ID:xiaobailc,项目名称:Gitamin,代码行数:15,代码来源:Authenticate.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         //return redirect('/user/dashboard');
     }
     return $next($request);
 }
开发者ID:pcmquizon,项目名称:127-Overflow,代码行数:14,代码来源:RedirectIfAuthenticated.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param Request $request The current request.
  * @param Closure $next    The handler to receive the request.
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if ($this->auth->check()) {
         return Redirect::route('home');
     }
     return $next($request);
 }
开发者ID:lovett,项目名称:toils,代码行数:15,代码来源:RedirectIfAuthenticated.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         return \Redirect::back();
     }
     return $next($request);
 }
开发者ID:JFSolorzano,项目名称:Acordes,代码行数:14,代码来源:RedirectIfAuthenticated.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->auth->user()->isAdmin()) {
         return response('Unauthorized.', 401);
     }
     return $next($request);
 }
开发者ID:suitmedia,项目名称:suitcoda,代码行数:14,代码来源:AdminRole.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->auth->check() || !$this->auth->user()->hasRole($this->role)) {
         App::abort(401);
     }
     return $next($request);
 }
开发者ID:nich-mctishe,项目名称:laravel-framework,代码行数:14,代码来源:Role.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param int|string $permission
  * @return mixed
  * @throws \Bican\Roles\Exceptions\PermissionDeniedException
  */
 public function handle($request, Closure $next, $permission)
 {
     if ($this->auth->check() && $this->auth->user()->may($permission)) {
         return $next($request);
     }
     throw new PermissionDeniedException($permission);
 }
开发者ID:mcclainconcepts,项目名称:roles,代码行数:16,代码来源:VerifyPermission.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->auth->user()) {
         return redirect('/');
     }
     return $next($request);
 }
开发者ID:asarmiento,项目名称:CPHon,代码行数:14,代码来源:VerifictSession.php

示例12: handle

 /**
  * We're verifying that the current user is logged in to Cachet and is an admin level.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->auth->check() || $this->auth->check() && !$this->auth->user()->isAdmin) {
         throw new HttpException(401);
     }
     return $next($request);
 }
开发者ID:guduchango,项目名称:Cachet,代码行数:15,代码来源:Admin.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param int $level
  * @return mixed
  * @throws \Bican\Roles\Exceptions\LevelDeniedException
  */
 public function handle($request, Closure $next, $level)
 {
     if ($this->auth->check() && $this->auth->user()->level() >= $level) {
         return $next($request);
     }
     throw new LevelDeniedException($level);
 }
开发者ID:eunion,项目名称:roles,代码行数:16,代码来源:VerifyLevel.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         return redirect(route('backend.dashboard'));
     }
     return $next($request);
 }
开发者ID:dipeshrijal,项目名称:blogcms,代码行数:14,代码来源:RedirectIfAuthenticated.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         return redirect()->route('event.index');
     }
     return $next($request);
 }
开发者ID:rob-meh,项目名称:weddinger,代码行数:14,代码来源:RedirectIfAuthenticated.php


注:本文中的Illuminate\Contracts\Auth\Guard类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。