1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-10 19:16:22 +02:00

Move 'updatePassword' method from class 'Auth' to class 'UserManager'

This commit is contained in:
maxsenft
2018-03-20 15:41:57 +01:00
committed by Marco
parent ec6afdad48
commit 1d54ff2f6b
2 changed files with 22 additions and 22 deletions

View File

@ -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)
*

View File

@ -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
*