Advertisement
Guest User

Untitled

a guest
May 26th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. class Guard
  2. {
  3.  
  4.     ...
  5.  
  6.     public function __construct($tokenGetter = null, $signer = null)
  7.     {
  8.         $this->signer = $signer ?? new Sha256();
  9.         $this->tokenGetter = $tokenGetter ?? app(TokenGetter::class);
  10.     }
  11.  
  12.     public function user() :? UserContract
  13.     {
  14.         if (is_null($this->user) === false) {
  15.             return $this->user;
  16.         }
  17.  
  18.         try {
  19.             $token = $this->resolveToken($this->tokenGetter->getToken());
  20.         } catch (TokenNotPresentException $ex) {
  21.             return null;
  22.         }
  23.  
  24.         $this->claims = $token->getClaims();
  25.  
  26.         return $this->user = $token->getUser();
  27.     }
  28.  
  29.     ...
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement