Commit 49d2d786 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Improved factorization

parent 8a7e6ccc
Pipeline #7418 passed with stage
in 14 seconds
......@@ -136,6 +136,10 @@ function is_key_matching($key, $account) {
Logger::getInstance()->error("Key doesn't match");
return false;
}
// Key is one time only
$account->confirmation_key = INVALID_CONFIRMATION_KEY;
$account->update();
return true;
}
......
......@@ -260,9 +260,6 @@ function xmlrpc_activate_phone_account($method, $args) {
if (!is_key_matching($key, $account)) {
return KEY_DOESNT_MATCH;
}
// Key is one time only
$account->confirmation_key = INVALID_CONFIRMATION_KEY;
$account->update();
// If this is a recovery, account is already activated, don't go through the following again
if (!is_activated($account->activated)) {
......@@ -439,12 +436,10 @@ function xmlrpc_activate_email_account($method, $args) {
return KEY_DOESNT_MATCH;
}
$expiration = NULL;
$account->activated = "1";
// Key is one time only
$account->confirmation_key = INVALID_CONFIRMATION_KEY;
$account->update();
$expiration = NULL;
// TODO
/*if (USE_IN_APP_PURCHASES) {
$expiration = get_trial_expiration_date();
......@@ -693,9 +688,6 @@ function xmlrpc_recover_account_from_confirmation_key($method, $args) {
if (!is_key_matching($key, $account)) {
return KEY_DOESNT_MATCH;
}
// Key is one time only
$account->confirmation_key = INVALID_CONFIRMATION_KEY;
$account->update();
$password = new Password($db);
$password->account_id = $account->id;
......
......@@ -128,13 +128,10 @@ function xmlrpc_activate_phone_number_link($method, $args) {
if (!is_activated($account->activated)) {
return ACCOUNT_NOT_YET_ACTIVATED;
}
if (!is_key_matching($key, $account)) {
return KEY_DOESNT_MATCH;
}
// Key is one time only
$account->confirmation_key = INVALID_CONFIRMATION_KEY;
$account->update();
$password = new Password($db);
$password->account_id = $account->id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment