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

Implement method 'changePasswordForUserByUsername' in 'Administration'

This commit is contained in:
maxsenft
2018-03-20 15:50:44 +01:00
committed by Marco
parent e14f3d1925
commit 131aea3ded

View File

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