/** * 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); } // return the new token return $this->encode($this->payloadFactory->make(['sub' => $payload['sub'], 'iat' => $payload['iat']])); }
/** * Register the bindings for the Payload Factory. */ protected function registerPayloadFactory() { $this->app['tymon.jwt.payload.factory'] = $this->app->share(function ($app) { $factory = new PayloadFactory($app['tymon.jwt.claim.factory'], $app['request'], $app['tymon.jwt.validators.payload']); return $factory->setTTL($this->config('ttl')); }); }
/** * Set the refresh flow. * * @param bool $refreshFlow * @return $this * @static */ public static function setRefreshFlow($refreshFlow = true) { return \Tymon\JWTAuth\PayloadFactory::setRefreshFlow($refreshFlow); }