Handle an incoming request.

@param  \Illuminate\Http\Request  $request
@param  \Closure  $next

@throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException

@return mixed
8927
public function handle($request, Closure $next)
    {
        $this->authenticate($request);

        $response = $next($request);

        // Send the refreshed token back to the client.
        return $this->setAuthenticationHeader($response);
    }
1259985
public function handle(Request $request, Closure $next)
    {
        if ( ! $this->isAllowed())
            $this->failedAuthorization();

        return $next($request);
    }
981663
public function handle($request, Closure $next)
    {
        $resource = $request->route()->getActionName();
        $permission = Permission::where('resource', '=', $resource)->first();

        // If the specific route requires permissions
        if ($permission) {
            // Get user permissions
            try {
                $user_permissions = Auth::user()->role->permissions->keyBy('resource');
            } catch (\Exception $e) {
                return abort(401, trans('acl::general.messages.user_permissions_not_found'));
            }

            // And the user has permissions
            if (! $user_permissions->has($resource)) {
                return abort(401, trans('acl::general.messages.no_permissions'));
            }
        }

        return $next($request);
    }
1065721
public function handle($request, Closure $next)
    {
        if (auth()->check() && (auth()->user()->hasPermission('admin-api-access') || auth()->user()->isSuperAdmin())) {
            return $next($request);
        }
        return abort(404, 'Not Found');
    }
87350
public function handle($request, Closure $next)
    {
        $response = $next($request);

        tracker()->saveCurrent();

        return $response;
    }
959698
public function handle(Request $request, \Closure $next)
    {
        if (!Admin::user()) {
            return $next($request);
        }

        if (!Admin::user()->allPermissions()->first(function ($permission) use ($request) {
            return $permission->shouldPassThrough($request);
        })) {
            \Core\Admin\Auth\Permission::error();
        }

        return $next($request);
    }
1054986
public function handle($request, Closure $next)
    {
        $this->credentials->getThrottleProvider()->enable();

        return $next($request);
    }
257664
public function handle(Request $request, \Closure $next) {
        if ($request->getMethod() == 'OPTIONS') {
            $response = new Response("", 200);
        }
        else {
            try{
                $response = $next($request);
            }catch(\Exception $e){
                $response = $this->exceptionRenderer->render($e);
            }
        }
        $this->setCorsHeaders($request, $response);
        return $response;
    }
463485
public function handle($request, \Closure $next)
    {
        $route = $request->route();

        if ($route->hasCondition()) {
            $this->router->addWordPressBindings($route);
        }

        return $next($request);
    }
1355865
public function handle($request, Closure $next)
    {
        $as = $request->input('_as');

        if ($this->authorize() && ! is_null($as)) {
            $this->auth->loginUsingId($as);

            return $this->response->redirectTo($request->url());
        }

        return $next($request);
    }
52718
public function handle($request, Closure $next)
    {
        $response = $next($request);

        if ($response instanceof Response) {
            $response->isNotModified($request);
        }

        return $response;
    }
341479
public function handle( $request, Closure $next )
	{
		$response = $next( $request );

		foreach ( $this->cookies->getQueuedCookies() as $cookie )
			$response->headers->setCookie( $cookie );

		return $response;
	}
166804
public function handle(Request $request, Closure $next)
    {
        $request->attributes->add(['responsecache.doNotCache' => true]);

        return $next($request);
    }
1235603
public function handle($request, Closure $next)
    {
        if (!Gate::allows('access', $request)) {
            return response('Forbidden (No Access)', 403);
        }
        return $next($request);
    }
462069
public function handle($request, Closure $next)
    {
        $token = $this->getTokenFromRequest($request);
        $this->jwt->setToken($token)->validateOrFail();

        return $next($request);
    }
1035872
public function handle(Request $request, Closure $next)
    {
        // 1. Check global permission
        $rule = $this->settings->get('permission');

        $response = $this->guard->isPermissionGranted(
            app($rule)->validate()
        );

        if (!$response) {
            auth('admin')->logout();

            return response()
                ->redirectGuest($this->loginUrl)
                ->with('redirect', $request->url());
        }

        if ($this->isResponseObject($response)) {
            return $response;
        }

        if ($this->redirectReceived($response)) {
            return $response->with('redirect', $request->url());
        }

        return $next($request);
    }
55542
public function handle($request, Closure $next)
    {
        // Get the required roles from the route
        $roles = $this->getRequiredRoleForRoute($request->route());
        // Check if a role is required for the route, and
        // if so, ensure that the user has that role.
        if ($request->user()->hasRole($roles) || !$roles) {
            return $next($request);
        }

        return response([
            'error' => [
                'code' => 'INSUFFICIENT_ROLE',
                'description' => 'You are not authorized to access this resource.',
            ],
        ], 401);
    }