Skip to content

Commit 0376a6d

Browse files
add changePasswordByJWT (#160)
1 parent 2b43f36 commit 0376a6d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/FusionAuthClient.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,25 @@ export class FusionAuthClient {
158158
.go();
159159
}
160160

161+
/**
162+
* Changes a user's password using their access token (JWT) instead of the changePasswordId
163+
* A common use case for this method will be if you want to allow the user to change their own password.
164+
*
165+
* Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword.
166+
*
167+
* @param {string} encodedJWT The encoded JWT (access token).
168+
* @param {ChangePasswordRequest} request The change password request that contains all the information used to change the password.
169+
* @returns {Promise<ClientResponse<ChangePasswordResponse>>}
170+
*/
171+
changePasswordByJWT(encodedJWT: string, request: ChangePasswordRequest): Promise<ClientResponse<ChangePasswordResponse>> {
172+
return this.startAnonymous<ChangePasswordResponse, Errors>()
173+
.withUri('/api/user/change-password')
174+
.withAuthorization('Bearer ' + encodedJWT)
175+
.withJSONBody(request)
176+
.withMethod("POST")
177+
.go();
178+
}
179+
161180
/**
162181
* Changes a user's password using their identity (loginId and password). Using a loginId instead of the changePasswordId
163182
* bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword

0 commit comments

Comments
 (0)