Skip to content
Permalink
Browse files

Don't fail if account has a password already

  • Loading branch information
flack committed Dec 14, 2019
1 parent f81b08c commit a0a105797e627ceb4621a94e6bdc461532acad43
Showing with 6 additions and 9 deletions.
  1. +6 −9 lib/org/openpsa/user/accounthelper.php
@@ -432,22 +432,19 @@ public function close_account() : bool

/**
* Reopen a blocked account.
*
* This will fail if someone set a new password on the account while it was blocked
*/
public function reopen_account()
{
$account = new midcom_core_account($this->person);
if ($account->get_password()) {
$this->person->delete_parameter('org_openpsa_user_blocked_account', 'account_password');
$msg = 'Account for person #' . $this->person->id . ' does have a password already';
throw new midcom_error($msg);
debug_add('Account for person #' . $this->person->id . ' does have a password already');
} else {
$account->set_password($this->person->get_parameter('org_openpsa_user_blocked_account', 'account_password'), false);
if (!$account->save()) {
throw new midcom_error('Failed to save account: ' . midcom_connection::get_error_string());
}
}

$account->set_password($this->person->get_parameter('org_openpsa_user_blocked_account', 'account_password'), false);
if (!$account->save()) {
throw new midcom_error('Failed to save account: ' . midcom_connection::get_error_string());
}
$this->person->delete_parameter('org_openpsa_user_blocked_account', 'account_password');
}

0 comments on commit a0a1057

Please sign in to comment.
You can’t perform that action at this time.