mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-03 14:47:30 +02:00
Implement new method 'changePasswordWithoutOldPassword' in 'Auth'
This commit is contained in:
20
src/Auth.php
20
src/Auth.php
@@ -638,6 +638,26 @@ final class Auth extends UserManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the currently signed-in user's password without requiring the old password for verification
|
||||||
|
*
|
||||||
|
* @param string $newPassword the new password that should be set
|
||||||
|
* @throws NotLoggedInException if the user is not currently signed in
|
||||||
|
* @throws InvalidPasswordException if the desired new password has been invalid
|
||||||
|
* @throws AuthError if an internal problem occurred (do *not* catch)
|
||||||
|
*/
|
||||||
|
public function changePasswordWithoutOldPassword($newPassword) {
|
||||||
|
if ($this->isLoggedIn()) {
|
||||||
|
$newPassword = self::validatePassword($newPassword);
|
||||||
|
$userId = $this->getUserId();
|
||||||
|
$this->updatePassword($userId, $newPassword);
|
||||||
|
$this->deleteRememberDirective($userId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new NotLoggedInException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the given user's password by setting it to the new specified password
|
* Updates the given user's password by setting it to the new specified password
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user