From b6afd91a2e976bc3158381046edada9b598cd9a8 Mon Sep 17 00:00:00 2001 From: Brady Wied Date: Thu, 12 Jun 2025 11:48:21 -0600 Subject: [PATCH] client builder sb build --- src/FusionAuth/FusionAuthClient.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/FusionAuth/FusionAuthClient.php b/src/FusionAuth/FusionAuthClient.php index 2beb35f..f5c9ad4 100644 --- a/src/FusionAuth/FusionAuthClient.php +++ b/src/FusionAuth/FusionAuthClient.php @@ -184,6 +184,27 @@ public function changePassword($changePasswordId, $request) ->go(); } + /** + * Changes a user's password using their access token (JWT) instead of the changePasswordId + * A common use case for this method will be if you want to allow the user to change their own password. + * + * Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword. + * + * @param string $encodedJWT The encoded JWT (access token). + * @param array $request The change password request that contains all the information used to change the password. + * + * @return ClientResponse The ClientResponse. + * @throws \Exception + */ + public function changePasswordByJWT($encodedJWT, $request) + { + return $this->startAnonymous()->uri("/api/user/change-password") + ->authorization("Bearer " . $encodedJWT) + ->bodyHandler(new JSONBodyHandler($request)) + ->post() + ->go(); + } + /** * Changes a user's password using their identity (loginId and password). Using a loginId instead of the changePasswordId * bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword