From 131aea3ded311cfc2b5dfbc2cdb0dc9c8e177825 Mon Sep 17 00:00:00 2001 From: maxsenft Date: Tue, 20 Mar 2018 15:50:44 +0100 Subject: [PATCH] Implement method 'changePasswordForUserByUsername' in 'Administration' --- src/Administration.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Administration.php b/src/Administration.php index 3beaf62..2f9ef0d 100644 --- a/src/Administration.php +++ b/src/Administration.php @@ -371,6 +371,27 @@ final class Administration extends UserManager { } } + /** + * Changes the password for the user with the given username + * + * @param string $username the username of the user whose password to change + * @param string $newPassword the new password to set + * @throws UnknownUsernameException if no user with the specified username has been found + * @throws AmbiguousUsernameException if multiple users with the specified username have been found + * @throws AuthError if an internal problem occurred (do *not* catch) + */ + public function changePasswordForUserByUsername($username, $newPassword) { + $userData = $this->getUserDataByUsername( + \trim($username), + [ 'id' ] + ); + + $this->updatePasswordInternal( + (int) $userData['id'], + $newPassword + ); + } + /** * Deletes all existing users where the column with the specified name has the given value *