From b102db7fe48cad66f9f581210f630290dd44a331 Mon Sep 17 00:00:00 2001 From: Peio Rigaux Date: Tue, 25 Aug 2020 11:58:11 +0200 Subject: [PATCH] Use get_config_value to ensure that geoloc accounts are disabled if there is no config value --- flexisip-account-manager.spec | 2 +- src/misc/user_info.php | 2 +- src/objects/user_info.php | 4 ++-- src/xmlrpc/accounts_email.php | 4 ++-- src/xmlrpc/accounts_phone.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flexisip-account-manager.spec b/flexisip-account-manager.spec index 9bd93ff..9a952ab 100644 --- a/flexisip-account-manager.spec +++ b/flexisip-account-manager.spec @@ -8,7 +8,7 @@ #%define _datadir %{_datarootdir} #%define _docdir %{_datadir}/doc -%define build_number 24 +%define build_number 25 %define var_dir /var/opt/belledonne-communications %define opt_dir /opt/belledonne-communications/share/flexisip-account-manager %define env_file "$RPM_BUILD_ROOT/etc/flexisip-account-manager/flexiapi.env" diff --git a/src/misc/user_info.php b/src/misc/user_info.php index b2a29cb..19035a0 100644 --- a/src/misc/user_info.php +++ b/src/misc/user_info.php @@ -44,7 +44,7 @@ function update_account_user_info($username, $ha1, $firstname, $lastname, $gende $user_info = new UserInfo($db); $user_info->account_id = $account->id; - if (ENABLE_NEW_ACCOUNTS_GEOLOC) { + if (get_config_value(ENABLE_NEW_ACCOUNTS_GEOLOC, FALSE)) { Logger::getInstance()->debug("userInfo : Account ip after enable geoloc if " . $account->ip_address); $country_infos = Geoloc::getGeolocInfosFromIp($account->ip_address); if ($country_infos) { diff --git a/src/objects/user_info.php b/src/objects/user_info.php index 58bd932..4a6eeec 100644 --- a/src/objects/user_info.php +++ b/src/objects/user_info.php @@ -126,7 +126,7 @@ class UserInfo { $query = "INSERT INTO " . USER_INFO_DB_TABLE . " SET account_id=:account_id, firstname=:firstname, lastname=:lastname, gender=:gender, subscribe=:subscribe"; - if (ENABLE_NEW_ACCOUNTS_GEOLOC) { + if (get_config_value(ENABLE_NEW_ACCOUNTS_GEOLOC, FALSE)) { $query .= ", country_code=:country_code, country_name=:country_name"; } @@ -145,7 +145,7 @@ class UserInfo $stmt->bindParam(":gender", $this->gender); $stmt->bindParam(":subscribe", $this->subscribe); - if (ENABLE_NEW_ACCOUNTS_GEOLOC) { + if (get_config_value(ENABLE_NEW_ACCOUNTS_GEOLOC, FALSE)) { $this->country_code = htmlspecialchars(strip_tags($this->country_code)); $this->country_name = htmlspecialchars(strip_tags($this->country_name)); diff --git a/src/xmlrpc/accounts_email.php b/src/xmlrpc/accounts_email.php index 1393dc6..2433916 100644 --- a/src/xmlrpc/accounts_email.php +++ b/src/xmlrpc/accounts_email.php @@ -104,7 +104,7 @@ function xmlrpc_create_email_account($method, $args) //need username + domain //We call this function to set the geoloc if enabled - if (ENABLE_NEW_ACCOUNTS_GEOLOC) { + if (get_config_value(ENABLE_NEW_ACCOUNTS_GEOLOC, FALSE)) { return update_account_user_info($account->username, $hashed_password, null, null, "unknown", '0', $account->domain, $algo); } @@ -189,7 +189,7 @@ function xmlrpc_create_email_md5_sha256_account($method, $args) //We call this function to set the geoloc if enabled // args needed = [username, ha1, firstname, lastname, gender, subscribe, [domain], [algo]] //need username + domain - if (ENABLE_NEW_ACCOUNTS_GEOLOC) { + if (get_config_value(ENABLE_NEW_ACCOUNTS_GEOLOC, FALSE)) { return update_account_user_info($account->username, $md5_hash, null, null, "unknown", '0', $account->domain, MD5); } diff --git a/src/xmlrpc/accounts_phone.php b/src/xmlrpc/accounts_phone.php index 5cbd061..314cd9c 100644 --- a/src/xmlrpc/accounts_phone.php +++ b/src/xmlrpc/accounts_phone.php @@ -137,7 +137,7 @@ function xmlrpc_create_phone_account($method, $args) //We call this function to set the geoloc if enabled // args needed = [username, ha1, firstname, lastname, gender, subscribe, [domain], [algo]] //need username + domain - if (ENABLE_NEW_ACCOUNTS_GEOLOC) { + if (get_config_value(ENABLE_NEW_ACCOUNTS_GEOLOC, FALSE)) { return update_account_user_info($account->username, $hashed_password, null, null, "unknown", '0', $account->domain, $algo); }