From c494e0fa138231ac7ad1d0b893f2174a2ce9e334 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 21 Mar 2018 03:20:11 +0100 Subject: [PATCH] Throw 'UnknownIdException' in 'updatePasswordInternal' when no matches --- src/UserManager.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/UserManager.php b/src/UserManager.php index fa08583..50d65de 100644 --- a/src/UserManager.php +++ b/src/UserManager.php @@ -187,17 +187,22 @@ abstract class UserManager { * * @param int $userId the ID of the user whose password should be updated * @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) */ protected function updatePasswordInternal($userId, $newPassword) { $newPassword = \password_hash($newPassword, \PASSWORD_DEFAULT); try { - $this->db->update( + $affected = $this->db->update( $this->dbTablePrefix . 'users', [ 'password' => $newPassword ], [ 'id' => $userId ] ); + + if ($affected === 0) { + throw new UnknownIdException(); + } } catch (Error $e) { throw new DatabaseError();