Skip to content

Commit 6c2972b

Browse files
add changePasswordByJWT (#52)
1 parent 7cb106c commit 6c2972b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/FusionAuth/FusionAuthClient.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,27 @@ public function changePassword($changePasswordId, $request)
184184
->go();
185185
}
186186

187+
/**
188+
* Changes a user's password using their access token (JWT) instead of the changePasswordId
189+
* A common use case for this method will be if you want to allow the user to change their own password.
190+
*
191+
* Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword.
192+
*
193+
* @param string $encodedJWT The encoded JWT (access token).
194+
* @param array $request The change password request that contains all the information used to change the password.
195+
*
196+
* @return ClientResponse The ClientResponse.
197+
* @throws \Exception
198+
*/
199+
public function changePasswordByJWT($encodedJWT, $request)
200+
{
201+
return $this->startAnonymous()->uri("/api/user/change-password")
202+
->authorization("Bearer " . $encodedJWT)
203+
->bodyHandler(new JSONBodyHandler($request))
204+
->post()
205+
->go();
206+
}
207+
187208
/**
188209
* Changes a user's password using their identity (loginId and password). Using a loginId instead of the changePasswordId
189210
* bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword

0 commit comments

Comments
 (0)