Handle an incoming request.

@param \Illuminate\Http\Request $request
@param \Closure                 $next
@param string                   $route route name

@return \Illuminate\Http\RedirectResponse|mixed
499216
public function handle(Request $request, Closure $next, $route)
    {
        $router = $this->container->make('router');

        $currentRoute = $router->current();
        $action       = $currentRoute->getAction();

        if (isset($action['role'])) {
            $action['roles'] = $action['role'];
        }

        if (isset($action['permission'])) {
            $action['permissions'] = $action['permission'];
        }

        // Redirect guest to login screen if route has least one role or permission
        if ((isset($action['roles']) || isset($action['permissions'])) && !$this->keeper->check()) {
            $url      = $this->container->make('url');
            $log      = $this->container->make('log');
            $redirect = $this->container->make('redirect');

            $log->notice('Guest redirected to login screen', [
                'from' => $currentRoute->getName(),
                'to'   => $route,
            ]);

            return $redirect->guest($url->route($route));
        }

        return $next($request);
    }
36178
public function handle($request, Closure $next)
    {
        $this->core->menu()->initialize();

        return $next($request);
    }
776011
public function handle($request, Closure $next)
    {
        if (! session('links.password') || (Crypt::decrypt(session('links.password')) != config('links.password'))) {
            return redirect()
                ->route('links::login')
                ->with('msg', 'Your login has expired or does not exist.');
        }

        return $next($request);
    }
776169
public function handle($request, Closure $next)
    {
        $route = $request->route();

        $this->router->substituteBindings($route);

        $this->substituteImplicitBindings($route);

        return $next($request);
    }
353550
public function handle(Request $request, Closure $next)
    {
        $action = $this->container->make('router')->current()->getAction();

        if (array_key_exists('group', $action)) {
            $action['groups'] = $action['group'];
        }
        if (array_key_exists('role', $action)) {
            $action['roles'] = $action['role'];
        }
        if (array_key_exists('permission', $action)) {
            $action['permissions'] = $action['permission'];
        }

        // Check user access only if least one role or permission is added to current route
        if (array_key_exists('roles', $action) || array_key_exists('permissions', $action)) {
            $url      = $this->container->make('url');
            $config   = $this->container->make('config');
            $redirect = $this->container->make('redirect');

            // If user is not authenticated redirect to login route
            if (!$this->keeper->check()) {
                return $redirect->guest($url->route($config->get('vi-kon.auth.login.route')));
            }

            // Get roles and permissions
            $groups      = Arr::get($action, 'groups', []);
            $roles       = Arr::get($action, 'roles', []);
            $permissions = Arr::get($action, 'permissions', []);

            /** @noinspection ArrayCastingEquivalentInspection */
            if (!is_array($groups)) {
                $groups = [$groups];
            }
            /** @noinspection ArrayCastingEquivalentInspection */
            if (!is_array($roles)) {
                $roles = [$roles];
            }
            /** @noinspection ArrayCastingEquivalentInspection */
            if (!is_array($permissions)) {
                $permissions = [$permissions];
            }

            // If user is authenticated but has no permission to access given route then redirect to 403 route
            if ($this->keeper->hasGroups($groups) !== true ||
                $this->keeper->hasRoles($roles) !== true ||
                $this->keeper->hasPermissions($permissions) !== true
            ) {
                $router = $this->container->make('router');
                $log    = $this->container->make('log');

                $currentRoute = $router->current();

                $log->notice('User has no access to page', [
                    'user'        => $this->keeper->user()->toArray(),
                    'permissions' => $permissions,
                    'roles'       => $roles,
                    'groups'      => $groups,
                    'route'       => $currentRoute->getName(),
                ]);

                throw new AccessDeniedHttpException();
            }
        }

        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);
    }
217595
public function handle($request, Closure $next)
    {
        $this->app->setLocale($this->getCurrentLocale($request));

        return $next($request);
    }
890253
public function handle(Request $request, Closure $next)
    {
        if (!$this->service->isCorsRequest($request)) {
            return $next($request);
        }

        if ($this->service->isPreflightRequest($request)) {
            return $this->service->handlePreflightRequest($request);
        }

        return $this->service->handleRequest($request, $next($request));
    }
873539
public function handle(Request $request, \Closure $next)
	{
		$this->buildRepository($request);

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

        $headers = (new SecureHeaders(config('secure-headers', [])))->headers();

        foreach ($headers as $key => $value) {
            $response->headers->set($key, $value, true);
        }

        return $response;
    }
1060758
public function handle($request, Closure $next)
    {
        $redirect = Redirect::query();

        $redirect->where('from_url', $request->url());
        $redirect->orWhere('from_url', 'LIKE', '_' . $request->path() . '_');

        $redirect = $redirect->first(['to_url', 'status']);

        if ($redirect) {

            return \Redirect::to($redirect->to_url, $redirect->status);
        }

        return $next($request);
    }
676365
public function handle(Request $request, Closure $next)
    {
        if ($request->ajax() || $request->wantsJson()) {
            return $next($request);
        }

        return response('Method not allowed', 405);
    }
1365
public function handle($request, Closure $next)
    {
        $route = Route::currentRouteName();
        $method = $request->method();
        $parameters = Route::current()->parameters();
        $hackedRoute = routeHack($route,$parameters);

        // if user destroy route
        if (
            $method == 'GET'
            && in_array($route, $this->userDestroyRoutes)
            && !is_null(Request::route('users'))
            && Request::route('users')->id === Sentinel::getUser()->id
        ) {
            abort(403);
        }

//        dd($hackedRoute);
        if (
            $method == 'GET'
            && ! in_array($route, $this->exceptRoutes)
            && ! Sentinel::getUser()->is_super_admin
            && (
                (
                    ! in_array($route, $this->userRoutes)
                    || is_null(Request::route('users'))
                    || Request::route('users')->id !== Sentinel::getUser()->id
                )
                && ! hasPermission($hackedRoute)
            )
        ) {
            abort(403);
        }

        return $next($request);
    }
1259985
public function handle(Request $request, Closure $next)
    {
        if ( ! $this->isAllowed())
            $this->failedAuthorization();

        return $next($request);
    }
603681
public function handle(Request $request, Closure $next)
    {
        if (!$this->verificationService->mustBeVerified($request->route(), $this->guard)) {
            return $next($request);
        }

        if ($request->ajax()) {
            return response('Unauthorized.', 401);
        }

        return redirect()->to($this->verificationService->getPathToVerificationAction());
    }
464288
public function handle(Request $request, Closure $next)
    {
        // If the request URL is ignored from localization.
        if ($this->shouldIgnore($request)) return $next($request);

        $this->localization->setRouteNameFromRequest($request);

        return $next($request);
    }
1116163
public function handle($request, Closure $next)
    {
         if (Auth::check()) {
             return redirect()->route('laramin.dashboard');
            }
        return $next($request);
    }