Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/FusionAuthClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClientResponse<ChangePasswordResponse>>}
*
* @deprecated This method has been renamed to changePasswordUsingJWT, use that method instead.
*/
changePasswordByJWT(encodedJWT: string, request: ChangePasswordRequest): Promise<ClientResponse<ChangePasswordResponse>> {
return this.startAnonymous<ChangePasswordResponse, Errors>()
Expand All @@ -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<ClientResponse<ChangePasswordResponse>>}
*/
changePasswordUsingJWT(encodedJWT: string, request: ChangePasswordRequest): Promise<ClientResponse<ChangePasswordResponse>> {
return this.startAnonymous<ChangePasswordResponse, Errors>()
.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
Expand Down