Exemplo n.º 1
0
 /**
  * @param  User                 $user
  * @return \Tymon\JWTAuth\Token
  */
 public function generateTokenFromUser(User $user)
 {
     /** @var Payload $payload */
     $payload = $this->jwtManager->getPayloadFactory()->sub($user->getId())->make();
     $token = $this->jwtManager->encode($payload);
     return $token;
 }
Exemplo n.º 2
0
 /**
  * Generate a token using the user identifier as the subject claim.
  *
  * @param mixed $user
  * @param array $customClaims
  *
  * @return string
  */
 public function fromUser($user, array $customClaims = [])
 {
     $payload = $this->makePayload($user->{$this->identifier}, $customClaims);
     $ret = $this->manager->encode($payload)->get();
     $this->setUserModelAsObject($user);
     return $ret;
 }
Exemplo n.º 3
0
 /**
  * Generate a token using the user identifier as the subject claim.
  *
  * @param mixed $user
  * @param array $customClaims
  *
  * @return string
  */
 public function fromUser($user, array $customClaims = [])
 {
     $payload = $this->makePayload($user->{$this->identifier}, $customClaims);
     return $this->manager->encode($payload)->get();
 }