コード例 #1
0
ファイル: TokenTest.php プロジェクト: vercoutere/laravel-jwt
 /** @test */
 public function it_invalidates_old_tokens()
 {
     $this->setExpectedException('Vercoutere\\LaravelJwt\\Exceptions\\InvalidTokenException');
     $this->token->renew();
     Token::validate($this->token->getToken());
 }
コード例 #2
0
ファイル: JwtGuard.php プロジェクト: vercoutere/laravel-jwt
 /**
  * Authenticates and logs a user in from a token.
  * 
  * @param   String $token
  * 
  * @return Boolean
  */
 public function authenticateWithToken($token)
 {
     try {
         $token = Token::validate($token);
     } catch (InvalidTokenException $e) {
         return false;
     }
     $this->token = $token;
     // Retrieve the user from the handle in the token.
     $user = $this->provider->retrieveByCredentials([config('jwt.handle') => $token->getPayload()['aud']]);
     $this->login($user);
     return true;
 }