Handle an incoming request.

@param  \Illuminate\Http\Request $request
@param  Closure $next
@param  $permissions
@return mixed
173226
public function handle($request, Closure $next, $permissions)
	{
		if (auth()->guest() || !$request->user()->can(explode('|', $permissions))) {
			abort(403);
		}
		return $next($request);
	}
1231658
public function handle($request, Closure $next)
    {
        $this->authorizer->setRequest($request);

        $this->authorizer->checkAuthCodeRequest();

        return $next($request);
    }
1009960
public function handle($request, Closure $next, string $permission = '')
    {
        if (!$this->getTokenPermissions($request->header('Hc-Token'))->hasTokenPermission($permission))
            return HCLog::error('APP-003', trans ("HCApps::apps_tokens.access_denied"));

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

            if ($this->permissionsHelper->can($permissions)) {
                return $next($request);
            }

            return abort(403);
        }
        if ($request->ajax()) {
            return response('Unauthorized.', 401);
        } else {
            return redirect()->guest('auth/login');
        }
    }
309851
public function handle($request, Closure $next, ...$permissions)
    {
        $all = filter_var(array_values(array_slice($permissions, -1))[0], FILTER_VALIDATE_BOOLEAN);
        if ($this->auth->check() && $this->auth->user()->may($permissions, $all)) {
            return $next($request);
        }

        throw new PermissionDeniedException(implode(',', $permissions));
    }
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);
    }
1054986
public function handle($request, Closure $next)
    {
        $this->credentials->getThrottleProvider()->enable();

        return $next($request);
    }
1076884
public function handle($request, Closure $next, $value)
    {
        if (\Gate::denies($value)) {
            app()->abort(403, 'Missing permission \''.$value.'\'');
        }

        return $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'));
        }
    }
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);
    }
666273
public function handle($request, Closure $next, $permission)
    {
        if (! auth()->user() || ! auth()->user()->can($permission)) {
            if ($request->ajax()) {
                return response()->json([
                    'error' => [
                        'status_code' => 401,
                        'code'        => 'INSUFFICIENT_PERMISSIONS',
                        'description' => 'You are not authorized to access this resource.',
                    ],
                ], 401);
            }

            return abort(401, 'You are not authorized to access this resource.');
        }

        return $next($request);
    }
609954
public function handle($request, Closure $next)
    {
        if ($request->user()->hasPermission('admin-api-access') || $request->user()->isSuperAdmin()) {
            return $next($request);
        }
        return abort(404);
    }
1202645
public function handle($request, Closure $next)
    {
        if ($this->cors->isPreflightRequest($request)) {
            return $this->cors->handlePreflightRequest($request);
        }

        return $next($request);
    }
757562
public function handle(Request $request, Closure $next, $roles)
    {
        $accessDenied = true;

        if (!$user = $this->auth->getActiveUser()) {
            Flash::error(trans('dashboard::dashboard.flash.access_denied'));

            return redirect()->route('auth.login');
        }

        if (!is_array($roles)) {
            $roles = [$roles];
        }

        foreach ($roles as $role) {

            if (!$role = $this->role->getBySlug($role)) {
                continue;
            }

            if ($user->inRole($role)) {
                $accessDenied = false;
            }
        }

        if ($accessDenied) {
            Flash::error(trans('dashboard::dashboard.flash.access_denied'));

            // Redirect back to the previous page where request was made.
            return redirect()->back();
        }

        return $next($request);
    }
812246
public function handle($request, Closure $next)
    {
        if (! Current::port()) {
            return $next($request);
        }

        $uri = ltrim(Current::requestPath(), '/');

        if (starts_with($uri, 'sv/res/')) {
            ResourceActivityEvent::dispatch($request);
        }

        return $next($request);
    }
414210
public function handle($request, \Closure $next)
    {
        $token = $this->authenticate($request);
        $response = $next($request);

        if ($token) {
            $response->header('Authorization', 'Bearer ' . $token);
        }

        return $response;
    }
91230
public function handle($request, Closure $next, $permission)
    {
        if (!Auth::user())
        {
            abort(503, "Unauthorized request");
        }

        if (!Auth::user()->hasPermission($permission))
        {
            abort(503, "Unauthorized request");
        }
        return $next($request);
    }