/** * Invalidate a Token by adding it to the blacklist * * @param Token $token * @return boolean */ public function invalidate(Token $token) { if (!$this->blacklistEnabled) { throw new JWTException('You must have the blacklist enabled to invalidate a token.'); } return $this->blacklist->add($this->decode($token)); }
/** * Refresh a Token and return a new Token. * * @param \Tymon\JWTAuth\Token $token * * @return \Tymon\JWTAuth\Token */ public function refresh(Token $token) { $payload = $this->setRefreshFlow()->decode($token); if ($this->blacklistEnabled) { // invalidate old token $this->blacklist->add($payload); } // persist the subject and issued at claims $claims = array_merge($this->customClaims, ['sub' => $payload['sub'], 'iat' => $payload['iat']]); // return the new token return $this->encode($this->payloadFactory->customClaims($claims)->make()); }