Checks that a user is authenticated.
You can specify the guard that should be use for Laravel >= 5.2.
@param string|null $guard
324724
public function seeAuthentication($guard = null)
    {
        $auth = $this->app['auth'];

        if (method_exists($auth, 'guard')) {
            $auth = $auth->guard($guard);
        }

        $this->assertTrue($auth->check(), 'There is no authenticated user');
    }
626442
public function getDefaultAuth(): ?Guard
    {
        // By default, the Auth Facade does not return the
        // any actual authentication guard, but rather an
        // instance of \Illuminate\Auth\AuthManager.
        // Therefore, we make sure only to obtain its
        // "default guard", to make sure that its only the guard
        // instance that we obtain.
        $manager = Auth::getFacadeRoot();
        if (isset($manager)) {
            return $manager->guard();
        }
        return $manager;
    }
343073
public function login($userId, $guard = null)
    {
        $model = $this->modelForGuard(
            $guard = $guard ?: config('auth.defaults.guard')
        );

        $user = str_contains($userId, '@')
            ? (new $model)->where('email', $userId)->first()
            : (new $model)->find($userId);

        Auth::guard($guard)->login($user);
    }
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);
    }
682655
public function handle($request, Closure $next, ...$guards)
    {
        $this->authenticate($request, $guards);

        return $next($request);
    }
968775
public function getAuth(): ?Guard
    {
        if (!$this->hasAuth()) {
            $this->setAuth($this->getDefaultAuth());
        }
        return $this->auth;
    }
571919
protected function currentUserInfo($guard = null)
    {
        $response = $this->visit("/_dusk/user/{$guard}");

        return json_decode(strip_tags($response->driver->getPageSource()), true);
    }
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);
    }
31240
final public function authenticateBasic($realm = null)
	{
		if (! (
			array_key_exists('PHP_AUTH_USER', $_SERVER)
			and array_key_exists('PHP_AUTH_PW', $_SERVER))
			and ! empty($_SERVER['PHP_AUTH_USER'])
			and ! empty($_SERER['PHP_AUTH_PW'])
		) {
			$this->HTTPAuthenticate('Basic', array('realm' => $realm));
			return false;
		} else {
			$this->HTTP_user = $_SERVER['PHP_AUTH_USER'];
			$this->HTTP_pass = $_SERVER['PHP_AUTH_PW'];
			return true;
		}
	}
582696
public function handle($request, Closure $next, $guard = null)
    {
        try {
            if ($this->auth->guard($guard)->guest()) {
                throw new RestrictAccessException();
            }

            return $next($request);
        } catch (RestrictAccessException $e) {
            abort(401, $e->getMessage());
        }
    }
195670
public function protect($protect = null)
    {
        if ($protect === null) {
            return $this->_protect;
        }
        $this->_protect = $protect;

        return $this;
    }
957803
public function handle($request, Closure $next, $guard = null)
    {
        if (auth()->guard($guard)->check()) {
            return intend([
                'url' => route($request->route('accessarea').'.home'),
                'with' => ['success' => trans('cortex/foundation::messages.already_authenticated')],
            ]);
        }

        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);
    }
170892
public function handle($request, Closure $next, $guard = null)
    {
        if ($this->checkSharpUserAuthenticated($guard)) {
            return redirect(route("code16.sharp.home"));
        }

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

        $response = $next($request);

        if ($this->shouldReceiveFreshToken($request, $response)) {
            $response->withCookie($this->cookieFactory->make(
                $request->user($this->guard)->getKey(), $request->session()->token()
            ));
        }

        return $response;
    }
197299
public function guard($name = null)
    {
        $name = $name ?: $this->getDefaultDriver();

        return $this->guards[$name] ?? $this->guards[$name] = $this->resolve($name);
    }
111954
public function handle($request, Closure $next, $guard = null)
    {
        /** @var  \Arcanedev\LaravelAuth\Models\User  $user */
        $user = Auth::guard($guard)->user();

        if ( ! is_null($user) && $this->isEnabled())
            $user->updateLastActivity();

        return $next($request);
    }