Handle an incoming request.

@param  \Illuminate\Http\Request $request
@param  \Closure $next
@param  array|string $permissions
@return mixed
764238
public function handle($request, Closure $next, $permissions)
    {
        $abilities = is_array($permissions) ? $permissions : explode(',', $permissions);

        if (! auth()->check() || ! auth()->user()->canAtLeast($abilities)) {
            abort(403, 'You are not allowed to view this content!');
        }

        return $next($request);
    }
1163039
public function handle($request, Closure $next)
    {
        $guards = array_slice(func_get_args(), 2);

        $this->authenticate($guards);

        return $next($request);
    }
1002403
public function handle($request, Closure $next, $role)
    {
        $this->authorize($role);

        return $next($request);
    }
897449
public function handle(Request $request, Closure $next, $permission = null)
    {
        if (auth()->guest() || $request->user()->cant($permission)) {
            return $this->response->error(
                trans('HCCore::core.error.forbidden'),
                [],
                JsonResponse::HTTP_FORBIDDEN
            );
        }

        return $next($request);
    }
1001608
public function handle(Request $request, Closure $next)
    {
        $referer = $request->headers->get('referer');

        return $this->blocker->isBlocked($referer)
            ? $this->getBlockedResponse()
            : $next($request);
    }
172009
public function handle($request, Closure $next, $permission = null)
    {
        if (! app('Illuminate\Contracts\Auth\Guard')->guest()) {
            if ($request->user()->can($permission)) {
                return $next($request);
            }

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

        return response('Unauthorized.', 401);
    }
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);
    }
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);
    }
387853
public function handle(Request $request, Closure $next, $permission = null)
    {
        $namespace      = $this->resolver->resolve();
        $clear          = $this->resolver->getClear();
        $actionName     = $this->resolver->getAction();
        $controllerName = $this->resolver->getController();

        /** we need to know details about current action * */
        $action = Action::select(['id', 'component_id', 'name'])->where('name', $permission)->whereHas('extension', function($query) use($clear) {
                    $query->where('name', $clear);
                })->first();

        if (is_null($action)) {
            return $next($request);
        }
        /** let's make a better looking of runtime push */
        $pushable = [
            'namespace'    => $namespace,
            'component'    => $clear,
            'controller'   => $controllerName,
            'action'       => $permission,
            'method'       => $actionName,
            'component_id' => $action->component_id,
            'action_id'    => $action->id,
        ];
        Memory::make('runtime')->push('control', $pushable);
        $response = $next($request);

        return $response;
    }
71658
public function handle($request, Closure $next, $permissions, $team = null, $options = '')
    {
        if (!$this->authorization('permissions', $permissions, $team, $options)) {
            return $this->unauthorized();
        }

        return $next($request);
    }
861397
public function handle($request, Closure $next, $roles)
    {
        if (! empty($roles) && $this->auth->check()) {
            $roles = explode(':', $roles);

            if ($this->permissionsHelper->is($roles)) {
                return $next($request);
            }

            return abort(403);
        }
        if ($request->ajax()) {
            return response('Unauthorized.', 401);
        } else {
            return redirect()->guest('auth/login');
        }
    }
888282
public function handle($request, Closure $next)
    {
        if ($class = AdminManager::getAdminInstance()) {
            $class = get_class($class);
        }

        if (!$this->permissions->check($class)) {
            return $this->permissions->denied($class);
        }

        return $next($request);
    }
1102300
public function handle($request, Closure $next, $permissionName)
    {
        $permission = Permission::where('name', $permissionName)->first();
        if (!Auth::admin()->user()->hasPermission($permission)) {
            abort(403);
        }

        return $next($request);
    }
183790
public function handle($request, Closure $next, $permission)
    {
        if (! $user = $request->user()) {
            abort(403, "Access denied!");
        }

        if (! $user->can($permission)) {
            abort(403, "Access denied!");
        }

        return $next($request);
    }
1111493
public function handle($request, Closure $next, $role = null, $permission = null)
    {
        if (Auth::guest()) {
            return redirect('/admin/login');
        }

        if ($role && ! $request->user()->hasRole($role)) {
            throw new NotFoundHttpException;
        }

        if ($permission && ! $request->user()->can($permission)) {
            throw new NotFoundHttpException;
        }

        return $next($request);
    }