/**
  * @depends testShouldReturnsTokenProviderInstance
  */
 function testEncodeReturnsTokenObject(TokenContract $provider)
 {
     $identifier = 1;
     $token = $provider->encode($identifier, ['name' => 'foo']);
     $this->assertInstanceOf(Token::class, $token);
     $this->assertEquals($identifier, $token->getClaim('sub'));
     $this->assertCount(4, $token->getClaims());
     // [iat, exp, sub and name]
     $this->assertEquals('foo', $token->getClaim('name'));
 }
예제 #2
0
 /**
  * Create a new token from the user identifier
  * 
  * @param Authenticatable $user
  * @param Token
  */
 public function refreshToken(Authenticatable $user)
 {
     $claims = ['name' => $user->name, 'email' => $user->email, 'locale' => config('app.locale')];
     return $this->repository->encode($user->getAuthIdentifier(), $claims);
 }