Skip to content

Commit 46cb609

Browse files
add changePasswordByJWT (#105)
1 parent 2079746 commit 46cb609

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,25 @@ public ClientResponse<ChangePasswordResponse, Errors> changePassword(String chan
431431
.go();
432432
}
433433

434+
/**
435+
* Changes a user's password using their access token (JWT) instead of the changePasswordId
436+
* A common use case for this method will be if you want to allow the user to change their own password.
437+
* <p>
438+
* Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword.
439+
*
440+
* @param encodedJWT The encoded JWT (access token).
441+
* @param request The change password request that contains all the information used to change the password.
442+
* @return The ClientResponse object.
443+
*/
444+
public ClientResponse<ChangePasswordResponse, Errors> changePasswordByJWT(String encodedJWT, ChangePasswordRequest request) {
445+
return startAnonymous(ChangePasswordResponse.class, Errors.class)
446+
.uri("/api/user/change-password")
447+
.authorization("Bearer " + encodedJWT)
448+
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
449+
.post()
450+
.go();
451+
}
452+
434453
/**
435454
* Changes a user's password using their identity (loginId and password). Using a loginId instead of the changePasswordId
436455
* bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword

src/main/java/io/fusionauth/domain/search/SortField.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
/*
2-
* Copyright (c) 2018-2022, FusionAuth, All Rights Reserved
2+
* Copyright (c) 2018-2025, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
315
*/
416
package io.fusionauth.domain.search;
517

18+
import java.util.Objects;
19+
620
import com.inversoft.json.JacksonConstructor;
721
import com.inversoft.json.ToString;
822

@@ -46,6 +60,20 @@ public SortField(String name, Sort order, String missing) {
4660
this.missing = missing;
4761
}
4862

63+
@Override
64+
public boolean equals(Object o) {
65+
if (o == null || getClass() != o.getClass()) {
66+
return false;
67+
}
68+
SortField sortField = (SortField) o;
69+
return Objects.equals(missing, sortField.missing) && Objects.equals(name, sortField.name) && order == sortField.order;
70+
}
71+
72+
@Override
73+
public int hashCode() {
74+
return Objects.hash(missing, name, order);
75+
}
76+
4977
@Override
5078
public String toString() {
5179
return ToString.toString(this);

0 commit comments

Comments
 (0)