Handle an incoming request.
@param \Illuminate\Http\Request $request
@param Closure $next
@param null $guard
@param null $field
@return mixed
545149
public function handle($request, Closure $next, $guard = null, $field = null)
    {
        $ipsAuth = env('BASIC_AUTH_IP', '');
        $ipsAuth = explode(',', $ipsAuth);


        if (env('BASIC_AUTH', false) == true)
        {
            if (empty($ipsAuth) || !in_array($request->ip(), $ipsAuth))
            {
                return $this->auth->guard($guard)->basic() ?: $next($request);
            }

        }

        return $next($request);
    }
476351
public function handle($request, Closure $next)
    {
        if (!Auth::guest()) {
            $user = Admin::model('User')->find(Auth::id());

            return $user->hasPermission('browse_admin') ? $next($request) : redirect('/');
        }

        $urlLogin = route('admin.login');
        $urlIntended = $request->url();
        if ($urlIntended == $urlLogin) {
            $urlIntended = null;
        }

        return redirect($urlLogin)->with('url.intended', $urlIntended);
    }
180964
public function handle($request, Closure $next, $guard = 'admin')
    {
        if (Auth::guard($guard)->guest()) {
            return JsonResponse::create(['message' => 'you are not authorized to access this api', 'status' => false], 401);
        }

        $user = Auth::user();
        if (isset($user->language) && ! empty($user->language)) {
            App::setLocale($user->language);
        }

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

		foreach ( $this->cookies->getQueuedCookies() as $cookie )
			$response->headers->setCookie( $cookie );

		return $response;
	}
620365
public function handle($request, Closure $next, ...$guards)
    {
        config()->set('auth.defaults.guard', 'soda');

        try {
            $this->authenticate(['soda']);

            if (env('APP_ENV') == 'production' && $request->route()->getName() !== 'soda.reset-weak-password') {
                foreach ($this->unsafePasswords as $unsafePassword) {
                    if ($this->hasher->check($unsafePassword, $request->user()->getAuthPassword())) {
                        return Soda::resetPassword();
                    }
                }
            }
        } catch (AuthenticationException $e) {
            return $this->unauthenticated($request, $e);
        }

        return $next($request);
    }
268531
public function handle($request, Closure $next, ...$guards)
    {
        try {
            if(sharp_laravel_version_gte('5.7')) {
                // Laravel's API changed in 5.7
                // @see https://laravel.com/docs/5.7/upgrade
                $this->authenticate($request, $guards);

            } else {
                $this->authenticate($guards);
            }

            if($checkHandler = config('sharp.auth.check_handler')) {
                if(!app($checkHandler)->check(auth()->guard($guards[0] ?? null)->user())) {
                    throw new AuthenticationException();
                }
            }

        } catch (AuthenticationException $e) {
            if($request->wantsJson()) {
                return response()->json(['message' => "Unauthenticated user"], 401);
            }

            return redirect()->guest(
                config('sharp.auth.login_page_url', route("code16.sharp.login"))
            );
        }

        return $next($request);
    }
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);
    }
229938
public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            $user = Auth::guard($guard)->user();
            $site = $user->site ?: site();
            $root = $site->getRootUrl();
            $userSlug = getSlug('userhome');

            $url = $root.'/'.$userSlug;
            return redirect()->away($url);
        }

        return $next($request);
    }
128077
public function handle($request, Closure $next, $guard = null)
    {
        if ($this->auth->guard($guard)->guest()) {
            return response()->json([
                'error' => 1,
                'msg' => "没有权限，请确认是否传入有效的lbs_token！",
                'data' => [],
            ], 401);
        }

        return $next($request);
    }
1302476
public function handle($request, Closure $next, $guard = null)
    {
        if (Session::has('locale')) {
            app()->setLocale(session()->get('locale'));
            TranslatorFacade::setLocale(session()->get('locale'));
        }

        return $next($request);
    }
294154
public function handle($request, Closure $next, ?string $action = null)
    {
        if (! $this->authorize($action)) {
            return $this->responseOnUnauthorized($request);
        }

        return $next($request);
    }
1235603
public function handle($request, Closure $next)
    {
        if (!Gate::allows('access', $request)) {
            return response('Forbidden (No Access)', 403);
        }
        return $next($request);
    }
916880
public function handle($request, Closure $next, string $user = null)
    {
        $this->shield->verify($request->getUser(), $request->getPassword(), $user);

        return $next($request);
    }
336461
public function handle($request, Closure $next, $guard = null)
    {
        // Send a forbidden status if wizard should not be triggered
        if (TriggerHelper::hasWizardCompleted()) return $this->forbiddenResponse();

        // Get the current step from the route slug
        $currentStepSlug = $request->route()->getParameter('slug', '');
        \SetupWizard::initialize($currentStepSlug);

        // Share common data with our views
        view()->share('currentStep', \SetupWizard::currentStep());
        view()->share('allSteps', \SetupWizard::steps());

        // Proceed as usual
        return $next($request);
    }
1351242
public function handle(Request $request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            if ($request->expectsJson()) {
                return response()->json(Auth::user());
            }

            return redirect()->route('admin.dashboard');
        }

        return $next($request);
    }
708997
public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            return response()->json(['error' => 'Already authenticated.'], 400);
        }

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

        return $next($request);
    }