Handle an incoming request.

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

@return mixed
544557
public function handle(Request $request, Closure $next, $required = false)
    {
        if ($this->auth->guest()) {
            if ($apiToken = $request->header('X-Cachet-Token')) {
                try {
                    $this->auth->onceUsingId(User::findByApiToken($apiToken)->id);
                } catch (ModelNotFoundException $e) {
                    if ($required) {
                        throw new HttpException(401);
                    }
                }
            } elseif ($required) {
                throw new HttpException(401);
            }
        }

        return $next($request);
    }
200149
public function handle($request, Closure $next)
    {
        if (!$this->debugbar->isEnabled()) {
            abort(404);
        }

        return $next($request);

    }
396975
public function handle($request, Closure $next)
    {
        //dd("SecureURL and config = ".Config::get('lasallecmsfrontend.secureURL'));

        if ( (Config::get('lasallecmsfrontend.secureURL')) && (!$request->secure()) ) {
           // return redirect()->secure($request->getRequestUri());
            return redirect("https://{$_SERVER['HTTP_HOST']}" . $request->getRequestUri());
        }

        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);
    }
1359535
public function handle($request, Closure $next)
    {
        if (Config::get('cms.api-token') == $request->get('token')) {
            return $next($request);
        }

        return response('Unauthorized.', 401);
    }
986384
public function handle($request, Closure $next)
    {
        \App::setLocale(\Routelocale::getLocaleFromRoute());
        return $next($request);;
    }
41077
public function handle($request, Closure $next)
    {
        config(['request.timezone' => $this->determineRequestTimezone($request)]);

        return $next($request);
    }
980146
public function handle(Request $request, \Closure $next)
    {
        if ($this->shouldLogOperation($request)) {
            $log = [
                'user_id' => Merchant::user()->id,
                'path'    => $request->path(),
                'method'  => $request->method(),
                'ip'      => $request->getClientIp(),
                'input'   => json_encode($request->input()),
            ];

            OperationLogModel::create($log);
        }

        return $next($request);
    }
778043
public function handle($request, Closure $next)
    {
        $urlIsSigned = app('signed-url')->validate($request->fullUrl());

        if (! $urlIsSigned) {
            abort(403);
        }

        return $next($request);
    }
482743
public function handle($request, Closure $next) {

        // if logged in and requesting to see the login form, display the logout form
        if ((Auth::check()) && ($request->is('login'))) {
            return redirect()->route('auth.logout');
        }

        // if *not* logged in and requesting to see the logout form, display the login form
        if ((!Auth::check()) && ($request->is('logout'))) {
            return redirect()->route('auth.login');
        }

        // if logged in and requesting to see the password/email (reset request) form, then go home
        if ((Auth::check()) && ($request->is('password/email'))) {
            return redirect()->route('home');
        }

        // if logged in and requesting to see the password/reset (reset) form, then go home
        if ((Auth::check()) && ($request->is('password/reset'))) {
            return redirect()->route('home');
        }

        return $next($request);
    }
552989
public function handle($request, Closure $next)
    {

        $request = $this->requestConverter->toCmsRequest($request);

        $request->provideCmsPath(function($request){
            $this->attachCmsPath($request);
        });

        $this->injectRequest($request);

        $this->app['events']->fire($this->requestEventName,[$request, $this]);

        return $next($request);

    }
987842
public function handle(Request $request, Closure $next)
    {
        $request::setTrustedProxies([], $this->getTrustedHeaderNames()); // Reset trusted proxies between requests
        $this->setTrustedProxyIpAddresses($request);

        return $next($request);
    }
1202645
public function handle($request, Closure $next)
    {
        if ($this->cors->isPreflightRequest($request)) {
            return $this->cors->handlePreflightRequest($request);
        }

        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);
    }
166804
public function handle(Request $request, Closure $next)
    {
        $request->attributes->add(['responsecache.doNotCache' => true]);

        return $next($request);
    }
662550
public function handle($request, Closure $next)
    {
        if ($request->user() != null && $request->user()->permissionCan($request)) {
            return $next($request);
        }

        abort(403);

        return false;
    }
224119
public function handle($request, \Closure $next)
    {
        if ($request->expectsJson()) {
            return $next($request);
        }

        return json_response()->error([
            'message' => 'Invalid AJAX Request',
        ], $this->code);
    }