• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Auth\Guard类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Guard类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: authorize

 /**
  * @param Guard $auth
  * @param Roles $roles
  * @return bool
  */
 public function authorize(Guard $auth, Roles $roles)
 {
     if ($auth->check() && $roles->isAdmin()) {
         return true;
     }
     return false;
 }
开发者ID:bitller,项目名称:nova,代码行数:12,代码来源:CreateNewOfferRequest.php


示例4: doCreateAlbum

 public function doCreateAlbum(Guard $guard, Request $request)
 {
     if ($guard->guest()) {
         throw new AppException(AppException::NEED_SIGN_IN);
     }
     $musics = $request->get('musics');
     $coverImageId = $request->get('cover_image_id');
     $title = $request->get('title');
     $artist = $request->get('artist');
     $year = $request->get('year');
     $genre = $request->get('genre');
     $album = new Album();
     $album->title = $title;
     $album->artist = $artist;
     $album->year = $year;
     $album->genre = $genre;
     $album->coverImage()->associate($coverImageId);
     $album->user()->associate($guard->id());
     $album->save();
     foreach ($musics as $musicId) {
         /** @var Music $music */
         $music = Music::where('id', $musicId)->first();
         if (!$music) {
             continue;
         }
         $album->musics()->attach($musicId);
         if (!$music->coverImage) {
             $music->coverImage()->associate($album->coverImage);
             $music->save();
         }
     }
     return $this->buildResponse(trans('api.album.create.success'), Tools::toArray($album));
 }
开发者ID:lialosiu,项目名称:amaoto-core,代码行数:33,代码来源:AlbumController.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('SiteController@index');
     }
     return $next($request);
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:14,代码来源:RedirectIfAuthenticated.php


示例6: 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


示例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('/user/dashboard');
     }
     return $next($request);
 }
开发者ID:pcmquizon,项目名称:127-Overflow,代码行数:14,代码来源:RedirectIfAuthenticated.php


示例8: 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


示例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()) {
         return \Redirect::back();
     }
     return $next($request);
 }
开发者ID:JFSolorzano,项目名称:Acordes,代码行数:14,代码来源:RedirectIfAuthenticated.php


示例10: 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


示例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->check() || !$this->auth->user()->hasRole($this->role)) {
         App::abort(401);
     }
     return $next($request);
 }
开发者ID:nich-mctishe,项目名称:laravel-framework,代码行数:14,代码来源:Role.php


示例12: 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


示例13: 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


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: handle

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


示例19: 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() && !$request->user()->hasGroup('admin')) {
         return redirect('/');
     }
     return $next($request);
 }
开发者ID:jeremytubbs-deprecated,项目名称:L51-Start-Here,代码行数:14,代码来源:RedirectIfNotAdmin.php


示例20: 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 response()->json(null, 401);
     }
     return $next($request);
 }
开发者ID:php-soft,项目名称:laravel-comments,代码行数:14,代码来源:Authenticate.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Bus\Dispatcher类代码示例发布时间:2022-05-23
下一篇:
PHP Auth\CanResetPassword类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap