mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Attempt to fix activation issue
This commit is contained in:
parent
43b34091af
commit
6d2cf23a80
8 changed files with 40 additions and 13 deletions
|
|
@ -8,7 +8,7 @@
|
|||
#%define _datadir %{_datarootdir}
|
||||
#%define _docdir %{_datadir}/doc
|
||||
|
||||
%define build_number 58
|
||||
%define build_number 59
|
||||
%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"
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ function get_trial_expiration_date()
|
|||
|
||||
function is_activated($activated)
|
||||
{
|
||||
return $activated == "1" || $activated == 1 || $activated;
|
||||
return $activated == "1";
|
||||
}
|
||||
|
||||
// XMLRPC parameters
|
||||
|
|
|
|||
|
|
@ -171,6 +171,25 @@ class Account
|
|||
return false;
|
||||
}
|
||||
|
||||
public function activate()
|
||||
{
|
||||
$query = "UPDATE " . ACCOUNTS_DB_TABLE . " SET activated=1 WHERE id=:id";
|
||||
|
||||
$stmt = $this->conn->prepare($query);
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
|
||||
$stmt->bindParam(":id", $this->id);
|
||||
|
||||
Logger::getInstance()->debug("Activating " . (string)$this);
|
||||
if ($stmt->execute()) {
|
||||
$this->activated = "1";
|
||||
return true;
|
||||
}
|
||||
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$query = "UPDATE " . ACCOUNTS_DB_TABLE . " SET username=:username, domain=:domain, activated=:activated";
|
||||
|
|
@ -298,7 +317,7 @@ class Account
|
|||
$this->username = $row['username'];
|
||||
$this->domain = $row['domain'];
|
||||
$this->email = $row['email'];
|
||||
$this->activated = $row['activated'];
|
||||
$this->activated = strval($row['activated']);
|
||||
$this->confirmation_key = $row['confirmation_key'];
|
||||
$this->ip_address = $row['ip_address'];
|
||||
$this->alias = $row['alias'];
|
||||
|
|
|
|||
|
|
@ -130,9 +130,11 @@ function xmlrpc_recover_account_from_confirmation_key($method, $args)
|
|||
return KEY_DOESNT_MATCH;
|
||||
}
|
||||
|
||||
Logger::getInstance()->message("Account activation status is " . $account->activated);
|
||||
if (!is_activated($account)) {
|
||||
$account->activated = "1";
|
||||
$account->update();
|
||||
if (!$account->activate()) {
|
||||
Logger::getInstance()->error("Failed to activate account !");
|
||||
}
|
||||
}
|
||||
|
||||
$password = new Password($db);
|
||||
|
|
|
|||
|
|
@ -228,8 +228,9 @@ function xmlrpc_activate_email_account($method, $args)
|
|||
return KEY_DOESNT_MATCH;
|
||||
}
|
||||
|
||||
$account->activated = "1";
|
||||
$account->update();
|
||||
if (!$account->activate()) {
|
||||
Logger::getInstance()->error("Failed to activate account id " . $account->id);
|
||||
}
|
||||
|
||||
$expiration = null;
|
||||
// TODO
|
||||
|
|
|
|||
|
|
@ -181,8 +181,9 @@ function xmlrpc_activate_phone_account($method, $args)
|
|||
// If this is a recovery, account is already activated, don't go through the following again
|
||||
if (!is_activated($account->activated)) {
|
||||
$expiration = null;
|
||||
$account->activated = "1";
|
||||
$account->update();
|
||||
if (!$account->activate()) {
|
||||
Logger::getInstance()->error("Failed to activate account id " . $account->id);
|
||||
}
|
||||
|
||||
$alias = new Alias($db);
|
||||
$alias->account_id = $account->id;
|
||||
|
|
@ -199,6 +200,9 @@ function xmlrpc_activate_phone_account($method, $args)
|
|||
if (CUSTOM_HOOKS) {
|
||||
hook_on_account_activated($account);
|
||||
}
|
||||
} else {
|
||||
Logger::getInstance()->warning("Account id " . $account->id . " was already activated");
|
||||
return ACCOUNT_ALREADY_ACTIVATED;
|
||||
}
|
||||
|
||||
$password = new Password($db);
|
||||
|
|
|
|||
|
|
@ -62,8 +62,10 @@ function activate_email_account($user, $domain, $key, $algo) {
|
|||
return KEY_DOESNT_MATCH;
|
||||
}
|
||||
|
||||
$account->activated = "1";
|
||||
$account->update();
|
||||
if (!$account->activate()) {
|
||||
Logger::getInstance()->error("[HTTP] Failed to activate account id " . $account->id);
|
||||
return;
|
||||
}
|
||||
Logger::getInstance()->message("[HTTP] Account activated");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -168,8 +168,7 @@ if (!empty($username)) {
|
|||
$logger->error("Password not found for account id " . $account->id);
|
||||
}
|
||||
|
||||
$account->activated = "1";
|
||||
if (!$account->update()) {
|
||||
if (!$account->activate()) {
|
||||
$logger->error("Failed to activate account id " . $account->id);
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue