mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-05 07:37:25 +02:00
Throw 'UnknownIdException' in 'updatePasswordInternal' when no matches
This commit is contained in:
@@ -187,17 +187,22 @@ abstract class UserManager {
|
|||||||
*
|
*
|
||||||
* @param int $userId the ID of the user whose password should be updated
|
* @param int $userId the ID of the user whose password should be updated
|
||||||
* @param string $newPassword the new password
|
* @param string $newPassword the new password
|
||||||
|
* @throws UnknownIdException if no user with the specified ID has been found
|
||||||
* @throws AuthError if an internal problem occurred (do *not* catch)
|
* @throws AuthError if an internal problem occurred (do *not* catch)
|
||||||
*/
|
*/
|
||||||
protected function updatePasswordInternal($userId, $newPassword) {
|
protected function updatePasswordInternal($userId, $newPassword) {
|
||||||
$newPassword = \password_hash($newPassword, \PASSWORD_DEFAULT);
|
$newPassword = \password_hash($newPassword, \PASSWORD_DEFAULT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->db->update(
|
$affected = $this->db->update(
|
||||||
$this->dbTablePrefix . 'users',
|
$this->dbTablePrefix . 'users',
|
||||||
[ 'password' => $newPassword ],
|
[ 'password' => $newPassword ],
|
||||||
[ 'id' => $userId ]
|
[ 'id' => $userId ]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($affected === 0) {
|
||||||
|
throw new UnknownIdException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Error $e) {
|
catch (Error $e) {
|
||||||
throw new DatabaseError();
|
throw new DatabaseError();
|
||||||
|
Reference in New Issue
Block a user