Handle an incoming request.

@param \Illuminate\Http\Request $request
@param \Closure  $next
@param string $role
@return mixed
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);
    }
1202645
public function handle($request, Closure $next)
    {
        if ($this->cors->isPreflightRequest($request)) {
            return $this->cors->handlePreflightRequest($request);
        }

        return $next($request);
    }
281062
public function handle($request, Closure $next, $permission = 'manage', $role = 'admin')
    {
        if (($status = $this->checkPermission($permission, $role)) !== true) {
            return response()->json(null, $status);
        }

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

        if ($route->hasCondition()) {
            $this->router->addWordPressBindings($route);
        }

        return $next($request);
    }
847950
public function handle($request, Closure $next, $role = 'super')
    {
        $roles = auth('admin')->user()->/* @scrutinizer ignore-call */roles()->pluck('name');
        if (in_array('super', $roles->toArray())) {
            return $next($request);
        }

        if (!in_array(strtolower($role), $roles->toArray())) {
            return redirect(route('admin.home'));
        }

        return $next($request);
    }
1369773
public function handle($request, Closure $next)
    {
        /**
         * @var $response Response
         */
        $response = $next($request);

        if ($request->isMethod('get') && !$request->ajax()) {
            $contentType = $response->headers->get('Content-Type');

            if (strpos($contentType, 'text/html') !== false) {
                $response->setContent($this->encryptHtml($response->getContent()));
            }
        }

        return $response;

    }
22310
public function handle($request, Closure $next)
    {
        if ($this->sessionConfigured()) {
            $request->setLaravelSession($this->startSession($request));
        }

        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');
        }
    }
1218707
public function handle($request, Closure $next)
    {
        if (! in_array($this->auth->user()->role->id, $this->allowed_roles)) {
            return redirect()->route('admin.dashboard');
        }

        return $next($request);
    }
340673
public function handle($request, Closure $next)
    {
        $route = $this->router->current()->methods()[0] . ' /' . $this->router->current()->uri();

        $isPermissionAllRoutes = RoutePermissionModel::getRoutePermissionsRoles('*');
        if ($isPermissionAllRoutes) {
            if (($user = $this->user($request)) === 401) {
                return response()->json(null, 401);
            }

            $hasRole  = $user->hasRole($isPermissionAllRoutes->roles, false);
            $hasPerms = $user->can($isPermissionAllRoutes->permissions, false);

            $hasRolePerm = $hasRole || $hasPerms || (is_array($isPermissionAllRoutes->roles) && in_array('@', $isPermissionAllRoutes->roles));

            if (!$hasRolePerm) {
                return response()->json(null, 403);
            }
        }

        $routePermission = RoutePermissionModel::getRoutePermissionsRoles($route);
        if ($routePermission) {
            if (($user = $this->user($request)) === 401) {
                return response()->json(null, 401);
            }

            $hasRole  = $user->hasRole($routePermission->roles, false);
            $hasPerms = $user->can($routePermission->permissions, false);

            $hasRolePerm = $hasRole || $hasPerms || (is_array($routePermission->roles) && in_array('@', $routePermission->roles));

            if (!$hasRolePerm) {
                return response()->json(null, 403);
            }
        }

        return $next($request);
    }
1000337
public function handle($request, Closure $next)
    {
        // unBind {locale} route parameter
        ! $request->route('locale') || $request->route()->forgetParameter('locale');

        return $next($request);
    }
380735
public function handle(Request $request, Closure $next)
    {
        $request->headers->set('Accept', 'application/json');

        return $next($request);
    }
78396
public function handle($request, Closure $next)
    {
        if (!Sentinel::check() || !Sentinel::inRole('admin')) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return Redirect::route('login');
            }
        }
        return $next($request);
    }
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);
    }
1235603
public function handle($request, Closure $next)
    {
        if (!Gate::allows('access', $request)) {
            return response('Forbidden (No Access)', 403);
        }
        return $next($request);
    }
552989
public function handle($request, Closure $next)
    {

        $request = $this->requestConverter->toCmsRequest($request);

        $request->provideCmsPath(function($request){
            $this->attachCmsPath($request);
        });

        $this->injectRequest($request);

        $this->app['events']->fire($this->requestEventName,[$request, $this]);

        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);
    }