More code for #857

This commit is contained in:
James Cole
2017-09-26 09:15:21 +02:00
parent 91e96aa4b9
commit d99adb515a
10 changed files with 137 additions and 4 deletions

View File

@@ -53,9 +53,14 @@ class UserRepository implements UserRepositoryInterface
}
/**
* This updates the users email address and records some things so it can be confirmed or undone later.
* The user is blocked until the change is confirmed.
*
* @param User $user
* @param string $newEmail
*
* @see updateEmail
*
* @return bool
*/
public function changeEmail(User $user, string $newEmail): bool
@@ -212,4 +217,29 @@ class UserRepository implements UserRepositoryInterface
{
return $user->hasRole($role);
}
/**
* This updates the users email address. Same as changeEmail just without most logging. This makes sure that the undo/confirm routine can't catch this one.
* The user is NOT blocked.
*
* @param User $user
* @param string $newEmail
*
* @see changeEmail
*
* @return bool
*/
public function updateEmail(User $user, string $newEmail): bool
{
$oldEmail = $user->email;
// save old email as pref
Preferences::setForUser($user, 'admin_previous_email_latest', $oldEmail);
Preferences::setForUser($user, 'admin_previous_email_' . date('Y-m-d-H-i-s'), $oldEmail);
$user->email = $newEmail;
$user->save();
return true;
}
}