From 2adf364c2c46cb8da446ae1a310599e31c53926a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 18 May 2021 16:54:33 +0300 Subject: [PATCH] provide base configuration object in login response to skip on initial getConfig --- classes/api.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/classes/api.php b/classes/api.php index 88e964b7c..18743d56d 100755 --- a/classes/api.php +++ b/classes/api.php @@ -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); }