provide base configuration object in login response to skip on initial getConfig

This commit is contained in:
Andrew Dolgov 2021-05-18 16:54:33 +03:00
parent 9f6237a1b8
commit 2adf364c2c
1 changed files with 12 additions and 1 deletions

View File

@ -74,7 +74,12 @@ class API extends Handler {
if ($uid = UserHelper::find_user_by_login($login)) {
if (get_pref(Prefs::ENABLE_API_ACCESS, $uid)) {
if (UserHelper::authenticate($login, $password, false, Auth_Base::AUTH_SERVICE_API)) {
// needed for _get_config()
UserHelper::load_user_plugins($_SESSION['uid']);
$this->_wrap(self::STATUS_OK, array("session_id" => session_id(),
"config" => $this->_get_config(),
"api_level" => self::API_LEVEL));
} else {
$this->_wrap(self::STATUS_ERR, array("error" => self::E_LOGIN_ERROR));
@ -370,7 +375,7 @@ class API extends Handler {
}
}
function getConfig() {
private function _get_config() {
$config = [
"icons_dir" => Config::get(Config::ICONS_DIR),
"icons_url" => Config::get(Config::ICONS_URL)
@ -383,6 +388,12 @@ class API extends Handler {
->where('owner_uid', $_SESSION['uid'])
->count();
return $config;
}
function getConfig() {
$config = $this->_get_config();
$this->_wrap(self::STATUS_OK, $config);
}