1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-04 15:17:28 +02:00

Throw 'UnknownIdException' in 'updatePasswordInternal' when no matches

This commit is contained in:
Marco
2018-03-21 03:20:11 +01:00
parent d7d9899167
commit c494e0fa13

View File

@@ -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();