X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FSecurity%2FBasicAuth.php;h=51da7a98ad472429d7f21b0d106b2129b8eb16f9;hb=cab469621d173015ade7846344f5051b600d640d;hp=b76073e8b328f1dbccf2388d6e16fe8e01958551;hpb=fa2c8cad9d4419182d3c72115d4f67cb1971ca13;p=friendica.git diff --git a/src/Security/BasicAuth.php b/src/Security/BasicAuth.php index b76073e8b3..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"); } @@ -182,15 +188,10 @@ class BasicAuth DI::auth()->setForUser($a, $record, false, false, $login_refresh); - Session::set('allow_api', true); + Hook::callAll('logged_in', $record); - Hook::callAll('logged_in', $a->user); + self::$current_user_id = DI::userSession()->getLocalUserId(); - if (Session::get('allow_api')) { - self::$current_user_id = local_user(); - } else { - self::$current_user_id = 0; - } return self::$current_user_id; } }