<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Exception;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
/**
- * Authentification via the basic auth method
+ * Authentication via the basic auth method
*/
class BasicAuth
{
}
Logger::debug('Access denied', ['parameters' => $_SERVER]);
// Checking for commandline for the tests, we have to avoid to send a header
- if (php_sapi_name() !== 'cli') {
+ if (DI::config()->get('system', 'basicauth') && (php_sapi_name() !== 'cli')) {
header('WWW-Authenticate: Basic realm="Friendica"');
}
throw new UnauthorizedException("This API requires login");
Hook::callAll('logged_in', $record);
- self::$current_user_id = local_user();
+ self::$current_user_id = DI::userSession()->getLocalUserId();
return self::$current_user_id;
}