當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。