Adldap\Laravel\Middleware\WindowsAuthenticate::handle PHP Method

handle() public method

Handle an incoming request.
public handle ( Illuminate\Http\Request $request, Closure $next ) : mixed
$request Illuminate\Http\Request
$next Closure
return mixed
    public function handle(Request $request, Closure $next)
    {
        if (!$this->auth->check()) {
            // Retrieve the SSO login attribute.
            $auth = $this->getWindowsAuthAttribute();
            // Retrieve the SSO input key.
            $key = key($auth);
            // Handle Windows Authentication.
            if ($account = $request->server($auth[$key])) {
                // Username's may be prefixed with their domain,
                // we just need their account name.
                $username = explode('\\', $account);
                if (count($username) === 2) {
                    list($domain, $username) = $username;
                } else {
                    $username = $username[key($username)];
                }
                if ($user = $this->retrieveAuthenticatedUser($key, $username)) {
                    $this->auth->login($user);
                }
            }
        }
        return $this->returnNextRequest($request, $next);
    }