X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FSecurity%2FBasicAuth.php;h=51da7a98ad472429d7f21b0d106b2129b8eb16f9;hb=cab469621d173015ade7846344f5051b600d640d;hp=2b4baaa36ed65f9be86c5ac46b80caaea9e145d4;hpb=abbe7895ae48570a9fc87b4ed85fd8a75c1c83f5;p=friendica.git diff --git a/src/Security/BasicAuth.php b/src/Security/BasicAuth.php index 2b4baaa36e..51da7a98ad 100644 --- a/src/Security/BasicAuth.php +++ b/src/Security/BasicAuth.php @@ -1,6 +1,6 @@ $_SERVER]); - header('WWW-Authenticate: Basic realm="Friendica"'); + // Checking for commandline for the tests, we have to avoid to send a header + if (DI::config()->get('system', 'basicauth') && (php_sapi_name() !== 'cli')) { + header('WWW-Authenticate: Basic realm="Friendica"'); + } throw new UnauthorizedException("This API requires login"); } @@ -187,15 +188,10 @@ class BasicAuth DI::auth()->setForUser($a, $record, false, false, $login_refresh); - Session::set('allow_api', true); - Hook::callAll('logged_in', $record); - if (Session::get('allow_api')) { - self::$current_user_id = local_user(); - } else { - self::$current_user_id = 0; - } + self::$current_user_id = DI::userSession()->getLocalUserId(); + return self::$current_user_id; } }