/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next, $scopesString = null) { if (Auth::guest()) { parent::handle($request, $next, $scopesString = null); } return $next($request); }
public function handle($request, Closure $next, $scopesString = null) { //try { $return = parent::handle($request, $next, $scopesString); //} catch (AccessDeniedException $e) { // $e->httpStatusCode == 401 ? $e->errorType = 'invalid_token' : null; // throw $e; //} return $return; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $scopesString * * @throws \League\OAuth2\Server\Exception\InvalidScopeException * * @return mixed */ public function handle($request, Closure $next, $scopesString = null) { $parent = $this; return parent::handle($request, function ($request) use($parent, $next) { $scopes = []; foreach ($this->authorizer->getScopes() as $scope) { $scopes[] = $scope->getId(); } switch ($this->authorizer->getResourceOwnerType()) { case 'user': $user = User::find($this->authorizer->getResourceOwnerId()); Gatekeeper::setIdentity(new OAuthUserIdentity($user, $this->authorizer->getClientId(), $scopes)); break; case 'client': Gatekeeper::setIdentity(new OAuthClientIdentity($this->authorizer->getClientId(), $scopes)); break; } return $next($request); }, $scopesString); }
/** * Create a new filter instance. * * @param Guard $auth * @return void */ public function __construct(Guard $auth, Authorizer $authorizer, $httpHeadersOnly = false) { $this->auth = $auth; parent::__construct($authorizer, $httpHeadersOnly); }