1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-30 21:00:13 +02:00

Implement new method 'changePasswordWithoutOldPassword' in 'Auth'

This commit is contained in:
Marco
2017-08-04 00:31:35 +02:00
parent e4f8673eab
commit 1800525b51

View File

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