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