]> git.mxchange.org Git - friendica.git/blobdiff - src/Security/BasicAuth.php
Remove unused parameter $network in Model\User::getDefaultGroup
[friendica.git] / src / Security / BasicAuth.php
index d4c8bc6dcb7df1a227a192d9471171e924149382..eaed9d22e5ae4a9659f37e0df1afae071f00a90b 100644 (file)
@@ -123,7 +123,6 @@ class BasicAuth
        private static function getUserIdByAuth(bool $do_login = true):int
        {
                $a = DI::app();
-               Session::set('allow_api', false);
                self::$current_user_id = 0;
 
                // workaround for HTTP-auth in CGI mode
@@ -178,7 +177,10 @@ class BasicAuth
                                return 0;
                        }
                        Logger::debug('Access denied', ['parameters' => $_SERVER]);
-                       header('WWW-Authenticate: Basic realm="Friendica"');
+                       // Checking for commandline for the tests, we have to avoid to send a header
+                       if (php_sapi_name() !== 'cli') {
+                               header('WWW-Authenticate: Basic realm="Friendica"');
+                       }
                        throw new UnauthorizedException("This API requires login");
                }
 
@@ -187,15 +189,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 = local_user();
+
                return self::$current_user_id;
        }
 }