From 93bc446c7a8833f1a7c1a986957d428c31db1402 Mon Sep 17 00:00:00 2001 From: Lyle Schemmerling Date: Wed, 23 Jul 2025 08:45:13 -0600 Subject: [PATCH] changePasswordUsingJWT --- src/FusionAuthClient.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/FusionAuthClient.ts b/src/FusionAuthClient.ts index 910b319..4f1a0b9 100644 --- a/src/FusionAuthClient.ts +++ b/src/FusionAuthClient.ts @@ -167,6 +167,8 @@ export class FusionAuthClient { * @param {string} encodedJWT The encoded JWT (access token). * @param {ChangePasswordRequest} request The change password request that contains all the information used to change the password. * @returns {Promise>} + * + * @deprecated This method has been renamed to changePasswordUsingJWT, use that method instead. */ changePasswordByJWT(encodedJWT: string, request: ChangePasswordRequest): Promise> { return this.startAnonymous() @@ -193,6 +195,25 @@ export class FusionAuthClient { .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 {ChangePasswordRequest} request The change password request that contains all the information used to change the password. + * @returns {Promise>} + */ + changePasswordUsingJWT(encodedJWT: string, request: ChangePasswordRequest): Promise> { + return this.startAnonymous() + .withUri('/api/user/change-password') + .withAuthorization('Bearer ' + encodedJWT) + .withJSONBody(request) + .withMethod("POST") + .go(); + } + /** * Check to see if the user must obtain a Trust Token Id in order to complete a change password request. * When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change