Launch function of the middleware.

@param  Request $request
@param  Callable $next
@return boolean
@throws
774439
public function process(Request $request, callable $next)
    {
        foreach ($this->preventOn() as $url) {
            if ($request->is($url)) {
                return $next($request);
            }
        }

        if ($request->isAjax()) {
            if ($request->getHeader('x-csrf-token') === session('_token')) {
                return $next($request);
            }

            response()->status(401);

            return response()->send('unauthorize.');
        }

        if ($request->get('_token') == $request->session()->get('_token')) {
            return $next($request);
        }

        throw new TokenMismatch('Token Mismatch');
    }
1078771
public function handle(Request $request, Closure $next)
    {
        if ($request->segment(1) == 'scaffold') {

            // allowed env-s check
            $allowed = collect(config('amranidev.config.env'))
                            ->contains(config('app.env'));

            if (!$allowed) {
                return redirect('/');
            }
        }

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

        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;
    }
1116163
public function handle($request, Closure $next)
    {
         if (Auth::check()) {
             return redirect()->route('laramin.dashboard');
            }
        return $next($request);
    }
1138221
public function handle(Request $request, Closure $next)
    {
        if (!empty($paths = $this->guardedPaths($request))) {
            $request->merge(
                array_map([$this, 'sanitizePath'], $paths)
            );
        }

        return $next($request);
    }
92410
public function handle(Request $request, Closure $next)
    {
        $asset = $request->route()->parameter('asset');

        if (!$asset->isPublic() && !$this->guard->check()) {
            abort(401);
        }

        if (!Asset::exists($asset)) {
            abort(404);
        }

        return $next($request);
    }
228455
public function handle($request, Closure $next)
    {
        $response = $next($request);
        $uri = $request->path();
        $nextUri = config('app.url').'/'.$uri;

        switch ($uri) {
            case 'verification/needed':
            case 'password/reset':
            case 'register':
            case 'logout':
            case 'login':
            case '/':
                break;

            default:
                session(['nextUri' => $nextUri]);

                if (config('laravel2step.laravel2stepEnabled')) {
                    if ($this->twoStepVerification($request) !== true) {
                        return redirect('verification/needed');
                    }
                }
                break;
        }

        return $response;
    }
169805
public function handle(Request $request, callable $next)
    {
        set_error_handler(
            function ($errorNumber, $errorString) {
                throw new \Exception($errorString, $errorNumber);
            }
        );

        try {
            $response = $next($request);

            if (!$response instanceof Response) {
                return new Response(
                    $this->get500(),
                    Response::HTTP_INTERNAL_SERVER_ERROR
                );
            }

            return $response;

        } catch (\Exception $exception) {
            switch ($exception->getCode()) {
                case Response::HTTP_NOT_FOUND:
                    return new Response(
                        $this->get404(),
                        Response::HTTP_NOT_FOUND
                    );
                default:
                    return new Response(
                        $this->get500(),
                        Response::HTTP_INTERNAL_SERVER_ERROR
                    );
            }
        }
    }
1253502
public function handle(Request $request, Closure $next)
    {
        /** @var Response $response */
        $response = $request->isXmlHttpRequest() === true ? $next($request) : $this->createForbiddenResponse();

        return $response;
    }
1306936
public function handle($request, Closure $next)
    {
        if ($this->auth->parser()->setRequest($request)->hasToken()) {
            try {
                $this->auth->parseToken()->authenticate();
            } catch (Exception $e) {
                //
            }
        }

        return $next($request);
    }
524705
public function handle(Request $request, Closure $next)
    {
        if (!$this->config->get('setting.enable_subscribers')) {
            return cachet_redirect('status-page');
        }

        return $next($request);
    }
1306203
public function handle(Request $request, Closure $next)
    {
        // Are we going to try and include embedded data?
        $this->response->getManager()->parseIncludes(explode(',', $request->get('include')));

        return $next($request);
    }
184650
public function handle($request, Closure $next)
    {
        if (! $this->auth->user()->meta->is_active) {
            return redirect()->guest('activate');
        }

        return $next($request);
    }
986384
public function handle($request, Closure $next)
    {
        \App::setLocale(\Routelocale::getLocaleFromRoute());
        return $next($request);;
    }
68290
public function handle(Request $request, Closure $next)
    {
        // If the request URL is ignored from localization.
        if ($this->shouldIgnore($request)) return $next($request);

        $segment = $request->segment(1, null);
        $locale  = session('locale', null);

        if ($this->localization->isLocaleSupported($segment)) {
            session()->put(['locale' => $segment]);

            return $next($request);
        }
        elseif ($this->localization->isDefaultLocaleHiddenInUrl()) {
            $locale = $this->localization->getDefaultLocale();
            session()->put(compact('locale'));
        }

        if (is_string($locale) && ! $this->isDefaultLocaleHidden($locale)) {
            session()->reflash();

            if ( ! is_null($redirect = $this->getLocalizedRedirect($locale)))
                return $redirect;
        }

        return $next($request);
    }
1301372
public function handle($request, Closure $next)
    {
        if ( ! $this->auth->check()) {

            if ($request->ajax() || $request->wantsJson()) {
                return response('Unauthorized.', 401);
            } else {
                /** @var CoreInterface $core */
                $core = app(Component::CORE);

                return redirect()->route( $core->prefixRoute(NamedRoute::AUTH_LOGIN) );
            }
        }

        return $next($request);
    }