Handle an incoming request.

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

@param                           $selectedNavigationId
@return mixed
@internal param null $guard
196576
public function handle($request, Closure $next, $selectedNavigationId)
    {
        $selectedNavigation = NavigationAdmin::findOrFail($selectedNavigationId);

        // check if user role is in navigation role
        $userRoles = user()->getRolesList();
        $navValid = $selectedNavigation->roles()->whereIn('roles.id', $userRoles)->first();

        if (!$navValid) {
            return redirect(user()->roles()->first()->slug);
        }

        return $next($request);
    }
1159509
public function handle($request, Closure $next, $guard = null, $field = null)
    {
        if (!App::environment(config('auth.environments', ['staging']))) {
            return $next($request);
        }

        return parent::handle($request, $next, $guard);
    }
26739
public function handle($request, Closure $next, $guard = 'admin')
    {
        config(['auth.defaults.guard' => 'admin']);

        $permissionName = $request->route()->getName();

        if (in_array($permissionName, ['admin.login', 'admin.login.post',
            'admin.password.reset.token', 'admin.password.email.post',
            'admin.password.reset.token', 'admin.password.reset',
        ])) {
            return $next($request);
        }

        if (Auth::guard($guard)->user()->is_super_admin == 1) {
            return $next($request);
        }

        $user = Auth::guard('admin')->user();

        if (!$user->hasPermission($permissionName)) {
            throw new \Exception('User Don\'t have permissions', 401);
        }

        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);
    }
274917
public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()->guest('login');
            }
        }

        return $next($request);
    }
526947
public function handle($request, Closure $next, $guard = null)
    {
        $request->setUserResolver(function () use ($request) {
            return \RMS\Auth\Service::getAuthInfo($request);
        });
        return $next($request);
    }
620049
public function handle($request, Closure $next, $guard = null)
    {
        $user = $request->user();

        if ($this->isAuthorized($user)) {
            return $next($request);
        }

        abort(401);
    }
200434
public function handle(Request $request, Closure $next, MediaTypeGuard $guard = null)
    {
        //
        $guard = $guard ?? app(MediaTypeGuard::class);

        if (!$guard->validateExistingContentType($request) || !$guard->hasCorrectHeadersForData($request)) {
            $errors = (new ErrorCollection())->add(ErrorFactory::buildUnsupportedMediaType());
            $encoder = Encoder::instance([], new EncoderOptions(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

            return new Response($encoder->encodeErrors($errors), 415, ['Content-Type' => $guard->getContentType()]);
        }

        if (!$guard->hasCorrectlySetAcceptHeader($request)) {
            $errors = (new ErrorCollection())->add(ErrorFactory::buildUnacceptable());
            $encoder = Encoder::instance([], new EncoderOptions(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

            return new Response($encoder->encodeErrors($errors), 406, ['Content-Type' => $guard->getContentType()]);
        }

        $response = $next($request);
        $response->header('Content-Type', $guard->getContentType());

        return $response;
    }
70296
public function handle($request, Closure $next)
    {
        if (!$this->auth->check())
            return redirect()->guest(route('admin.login'));

        app(Gate::class)->authorize('admin.dashboard');

        return $next($request);
    }
1289622
public function handle($request, Closure $next)
    {
        if (Gate::allows('admin', $this->auth->user())) {
            return $next($request);
        }

        return response()->view('errors.401', [], 401);
    }
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);
    }
776208
public function handle(Request $request, Closure $next)
    {
        $this->collectModules(function ($fileInfo) {
            $this->resolveClass($fileInfo, function ($module) {
                if ($module instanceof Module) {
                    $this->registerModule($module);
                }

                if ($this->navigableResource($module)
                    && ($navigation = $this->application->make('scaffold.navigation'))
                ) {
                    $this->makeNavigation($module, $navigation);
                }
            });
        });

        return $next($request);
    }
512505
public function handle($request, Closure $next, $guard = null)
    {
        $locale = $this->determinerManager->determineLocale($request);

        $this->app->setLocale($locale);

        return $next($request);
    }
305063
public function handle($request, Closure $next, $guard = null) {
		if (admin()->user()) {
			return redirect(aurl('/'));
		}
		return $next($request);

	}
362388
public function handle($request, Closure $next)
    {
        if ($this->auth->check() && $this->auth->user()->hasAccess($this->routeActive)) {
            return $next($request);
        } else {
            abort(404);
        }
    }
951150
public function handle($request, Closure $next, $permission)
    {
        if (!Sentinel::check()) {
            return $this->denied($request);
        }

        if (!Sentinel::hasAccess($permission)) {
            return $this->denied($request);
        }

        return $next($request);
    }
561035
public function handle($request, Closure $next, $role)
    {
        if (!Sentinel::check()) {
            return $this->denied($request);
        }

        if (!Sentinel::inRole($role)) {
            return $this->denied($request);
        }

        return $next($request);
    }