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


PHP Guard::setUser方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     try {
         $userAndKey = $this->key->extractKeyAndUser($request);
         if ($userAndKey) {
             /** @var User $user */
             $user = $userAndKey['user'];
             if ($user->isDisabled()) {
                 abort(403, 'User is disabled');
             }
             $this->manager->setUser($user);
         }
         return $next($request);
     } catch (InvalidAuthException $e) {
         abort(401, $e->getMessage());
     }
     abort(401, 'User could not be found.');
 }
开发者ID:vaidasm,项目名称:vault,代码行数:25,代码来源:ApiKeyMiddleware.php

示例2: __construct

 public function __construct(Request $request, Guard $auth)
 {
     // TODO: Add API keys and check here
     // Check the session token and authenticate the user.
     if ($sessionToken = $request->get('sessionToken')) {
         $user = $this->validateSessionToken($sessionToken);
         $auth->setUser($user);
     }
     parent::__construct($request, $auth);
 }
开发者ID:stickableapp,项目名称:stickable-api,代码行数:10,代码来源:ApiController.php

示例3: setUser

 /**
  * Set the current user.
  *
  * @param \Illuminate\Contracts\Auth\Authenticatable $user
  * @return void 
  * @static 
  */
 public static function setUser($user)
 {
     \Illuminate\Auth\Guard::setUser($user);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例4: setUser

 /**
  * Set the current user of the application.
  *
  * @param \Illuminate\Contracts\Auth\Authenticatable $user
  */
 public function setUser(UserContract $user)
 {
     parent::setUser($user);
     $this->resetRolesAndPermissions();
     $this->setRolesAndPermissions($user);
 }
开发者ID:veelasky,项目名称:foundry,代码行数:11,代码来源:Shield.php

示例5: setCurrentUser

 /**
  * Set the current user.
  *
  * @param UserModel $user
  */
 public function setCurrentUser(UserModel $user)
 {
     $this->auth->setUser($user);
 }
开发者ID:anlutro,项目名称:l4-core,代码行数:9,代码来源:UserManager.php

示例6: __construct

 public function __construct(Request $request, Guard $auth)
 {
     // TODO: Add API keys and check here
     if ($sessionKey = $request->get('sessionKey')) {
         /** @var UserSession $session */
         $session = UserSession::find($sessionKey);
         if (!$session) {
             throw new NotFoundHttpException("The given sessionKey is invalid.");
         }
         if (!$session->user) {
             throw new NotFoundHttpException("The user for that session could not be found.");
         }
         // Login the user just for this request.
         $auth->setUser($session->user);
     }
     parent::__construct($request, $auth);
 }
开发者ID:antriver,项目名称:ctrlv-api,代码行数:17,代码来源:ApiController.php


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