provide base configuration object in login response to skip on initial getConfig
This commit is contained in:
parent
9f6237a1b8
commit
2adf364c2c
|
@ -74,7 +74,12 @@ class API extends Handler {
|
||||||
if ($uid = UserHelper::find_user_by_login($login)) {
|
if ($uid = UserHelper::find_user_by_login($login)) {
|
||||||
if (get_pref(Prefs::ENABLE_API_ACCESS, $uid)) {
|
if (get_pref(Prefs::ENABLE_API_ACCESS, $uid)) {
|
||||||
if (UserHelper::authenticate($login, $password, false, Auth_Base::AUTH_SERVICE_API)) {
|
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(),
|
$this->_wrap(self::STATUS_OK, array("session_id" => session_id(),
|
||||||
|
"config" => $this->_get_config(),
|
||||||
"api_level" => self::API_LEVEL));
|
"api_level" => self::API_LEVEL));
|
||||||
} else {
|
} else {
|
||||||
$this->_wrap(self::STATUS_ERR, array("error" => self::E_LOGIN_ERROR));
|
$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 = [
|
$config = [
|
||||||
"icons_dir" => Config::get(Config::ICONS_DIR),
|
"icons_dir" => Config::get(Config::ICONS_DIR),
|
||||||
"icons_url" => Config::get(Config::ICONS_URL)
|
"icons_url" => Config::get(Config::ICONS_URL)
|
||||||
|
@ -383,6 +388,12 @@ class API extends Handler {
|
||||||
->where('owner_uid', $_SESSION['uid'])
|
->where('owner_uid', $_SESSION['uid'])
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getConfig() {
|
||||||
|
$config = $this->_get_config();
|
||||||
|
|
||||||
$this->_wrap(self::STATUS_OK, $config);
|
$this->_wrap(self::STATUS_OK, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue