From c3f20977509cf36ecd3daa1eb73c29fc7c5078f3 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 21 Mar 2018 02:35:09 +0100 Subject: [PATCH] Document 'changePasswordForUserByUsername' from 'Administration' --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 45d3e3c..0949e97 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Migrating from an earlier version of this project? See our [upgrade guide](Migra * [Taking roles away from users](#taking-roles-away-from-users) * [Checking roles](#checking-roles-1) * [Impersonating users (logging in as user)](#impersonating-users-logging-in-as-user) + * [Changing a user’s password](#changing-a-users-password) * [Cookies](#cookies) * [Renaming the library’s cookies](#renaming-the-librarys-cookies) * [Defining the domain scope for cookies](#defining-the-domain-scope-for-cookies) @@ -1001,6 +1002,23 @@ catch (\Delight\Auth\EmailNotVerifiedException $e) { } ``` +#### Changing a user’s password + +```php +try { + $auth->admin()->changePasswordForUserByUsername($_POST['username'], $_POST['newPassword']); +} +catch (\Delight\Auth\UnknownUsernameException $e) { + // unknown username +} +catch (\Delight\Auth\AmbiguousUsernameException $e) { + // ambiguous username +} +catch (\Delight\Auth\InvalidPasswordException $e) { + // invalid password +} +``` + ### Cookies This library uses two cookies to keep state on the client: The first, whose name you can retrieve using