Skip to content

Commit 9fab22f

Browse files
Merge pull request #130 from FusionAuth/lyle/ENG-2742/change-password-using-jwt
changePasswordUsingJWT
2 parents 05d4743 + 0ed6aa8 commit 9fab22f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main/java/io/fusionauth/client/FusionAuthClient.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ public ClientResponse<ChangePasswordResponse, Errors> changePassword(String chan
440440
* @param encodedJWT The encoded JWT (access token).
441441
* @param request The change password request that contains all the information used to change the password.
442442
* @return The ClientResponse object.
443+
* @deprecated This method has been renamed to changePasswordUsingJWT, use that method instead.
443444
*/
445+
@Deprecated
444446
public ClientResponse<ChangePasswordResponse, Errors> changePasswordByJWT(String encodedJWT, ChangePasswordRequest request) {
445447
return startAnonymous(ChangePasswordResponse.class, Errors.class)
446448
.uri("/api/user/change-password")
@@ -466,6 +468,25 @@ public ClientResponse<Void, Errors> changePasswordByIdentity(ChangePasswordReque
466468
.go();
467469
}
468470

471+
/**
472+
* Changes a user's password using their access token (JWT) instead of the changePasswordId
473+
* A common use case for this method will be if you want to allow the user to change their own password.
474+
* <p>
475+
* Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword.
476+
*
477+
* @param encodedJWT The encoded JWT (access token).
478+
* @param request The change password request that contains all the information used to change the password.
479+
* @return The ClientResponse object.
480+
*/
481+
public ClientResponse<ChangePasswordResponse, Errors> changePasswordUsingJWT(String encodedJWT, ChangePasswordRequest request) {
482+
return startAnonymous(ChangePasswordResponse.class, Errors.class)
483+
.uri("/api/user/change-password")
484+
.authorization("Bearer " + encodedJWT)
485+
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
486+
.post()
487+
.go();
488+
}
489+
469490
/**
470491
* Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
471492
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change

0 commit comments

Comments
 (0)