/** * @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; }
/** * 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; }
/** * 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(); }