/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle(Request $request, Closure $next) { if (!($token = $request->bearerToken())) { throw new InvalidTokenAuthorizationHeader(); } // Validate the vadility of the token try { $payload = $this->manager->setRefreshFlow($this->getRefreshFlow())->decode(new Token($token)); } catch (\Exception $e) { throw new InvalidToken(); } if (!$this->auth->onceUsingId($payload->get('sub'))) { throw new InvalidUser(); } return $next($request); }
/** * Get the Blacklist * * @return \Tymon\JWTAuth\Blacklist */ public function blacklist() { return $this->manager->getBlacklist(); }
/** * Register the bindings for the JWT Manager */ protected function registerManager() { $this->app->singleton('tymon.jwt.manager', function ($app) { $instance = new Manager($app['tymon.jwt.provider.jwt'], $app['tymon.jwt.blacklist'], $app['tymon.jwt.payload.factory']); return $instance->setBlacklistEnabled((bool) $this->config('blacklist_enabled')); }); }