/** * 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()); }
/** * Register the bindings for the Payload Factory */ protected function registerPayloadFactory() { $this->app->singleton('tymon.jwt.payload.factory', function ($app) { $factory = new Factory(new ClaimFactory(), $app['request'], $app['tymon.jwt.validators.payload']); return $factory->setTTL($this->config('ttl')); }); }