From 1d54ff2f6bb0802001d88c8ab60e3d37745ba87f Mon Sep 17 00:00:00 2001 From: maxsenft Date: Tue, 20 Mar 2018 15:41:57 +0100 Subject: [PATCH] Move 'updatePassword' method from class 'Auth' to class 'UserManager' --- src/Auth.php | 22 ---------------------- src/UserManager.php | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Auth.php b/src/Auth.php index 25dcce9..788a78d 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -725,28 +725,6 @@ final class Auth extends UserManager { } } - /** - * Updates the given user's password by setting it to the new specified password - * - * @param int $userId the ID of the user whose password should be updated - * @param string $newPassword the new password - * @throws AuthError if an internal problem occurred (do *not* catch) - */ - private function updatePassword($userId, $newPassword) { - $newPassword = \password_hash($newPassword, \PASSWORD_DEFAULT); - - try { - $this->db->update( - $this->dbTablePrefix . 'users', - [ 'password' => $newPassword ], - [ 'id' => $userId ] - ); - } - catch (Error $e) { - throw new DatabaseError(); - } - } - /** * Attempts to change the email address of the currently signed-in user (which requires confirmation) * diff --git a/src/UserManager.php b/src/UserManager.php index fa56e3e..e6e5832 100644 --- a/src/UserManager.php +++ b/src/UserManager.php @@ -182,6 +182,28 @@ abstract class UserManager { return $newUserId; } + /** + * Updates the given user's password by setting it to the new specified password + * + * @param int $userId the ID of the user whose password should be updated + * @param string $newPassword the new password + * @throws AuthError if an internal problem occurred (do *not* catch) + */ + protected function updatePassword($userId, $newPassword) { + $newPassword = \password_hash($newPassword, \PASSWORD_DEFAULT); + + try { + $this->db->update( + $this->dbTablePrefix . 'users', + [ 'password' => $newPassword ], + [ 'id' => $userId ] + ); + } + catch (Error $e) { + throw new DatabaseError(); + } + } + /** * Called when a user has successfully logged in *