Skip to content

Commit 68d36b0

Browse files
Merge pull request #136 from FusionAuth/lyle/ENG-2742/change-password-using-jwt
changePasswordUsingJWT
2 parents 3e33ea4 + 8a601e8 commit 68d36b0

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

fusionauth-netcore-client/src/io/fusionauth/FusionAuthClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public Task<ClientResponse<ChangePasswordResponse>> ChangePasswordAsync(string c
153153
}
154154

155155
/// <inheritdoc/>
156+
[Obsolete("This method has been renamed to ChangePasswordUsingJWTAsync, use that method instead.")]
156157
public Task<ClientResponse<ChangePasswordResponse>> ChangePasswordByJWTAsync(string encodedJWT, ChangePasswordRequest request) {
157158
return buildAnonymousClient()
158159
.withUri("/api/user/change-password")
@@ -171,6 +172,16 @@ public Task<ClientResponse<RESTVoid>> ChangePasswordByIdentityAsync(ChangePasswo
171172
.goAsync<RESTVoid>();
172173
}
173174

175+
/// <inheritdoc/>
176+
public Task<ClientResponse<ChangePasswordResponse>> ChangePasswordUsingJWTAsync(string encodedJWT, ChangePasswordRequest request) {
177+
return buildAnonymousClient()
178+
.withUri("/api/user/change-password")
179+
.withAuthorization("Bearer " + encodedJWT)
180+
.withJSONBody(request)
181+
.withMethod("Post")
182+
.goAsync<ChangePasswordResponse>();
183+
}
184+
174185
/// <inheritdoc/>
175186
public Task<ClientResponse<RESTVoid>> CheckChangePasswordUsingIdAsync(string changePasswordId) {
176187
return buildAnonymousClient()

fusionauth-netcore-client/src/io/fusionauth/FusionAuthSyncClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public ClientResponse<ChangePasswordResponse> ChangePassword(string changePasswo
8686
}
8787

8888
/// <inheritdoc/>
89+
[Obsolete("This method has been renamed to ChangePasswordUsingJWT, use that method instead.")]
8990
public ClientResponse<ChangePasswordResponse> ChangePasswordByJWT(string encodedJWT, ChangePasswordRequest request) {
9091
return client.ChangePasswordByJWTAsync(encodedJWT, request).GetAwaiter().GetResult();
9192
}
@@ -95,6 +96,11 @@ public ClientResponse<RESTVoid> ChangePasswordByIdentity(ChangePasswordRequest r
9596
return client.ChangePasswordByIdentityAsync(request).GetAwaiter().GetResult();
9697
}
9798

99+
/// <inheritdoc/>
100+
public ClientResponse<ChangePasswordResponse> ChangePasswordUsingJWT(string encodedJWT, ChangePasswordRequest request) {
101+
return client.ChangePasswordUsingJWTAsync(encodedJWT, request).GetAwaiter().GetResult();
102+
}
103+
98104
/// <inheritdoc/>
99105
public ClientResponse<RESTVoid> CheckChangePasswordUsingId(string changePasswordId) {
100106
return client.CheckChangePasswordUsingIdAsync(changePasswordId).GetAwaiter().GetResult();

fusionauth-netcore-client/src/io/fusionauth/IFusionAuthClient.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public interface IFusionAuthAsyncClient {
138138
/// contacted because it is down or experiencing a failure, the response will contain an Exception, which could be an
139139
/// IOException.
140140
/// </returns>
141+
[Obsolete("This method has been renamed to ChangePasswordUsingJWTAsync, use that method instead.")]
141142
Task<ClientResponse<ChangePasswordResponse>> ChangePasswordByJWTAsync(string encodedJWT, ChangePasswordRequest request);
142143

143144
/// <summary>
@@ -155,6 +156,23 @@ public interface IFusionAuthAsyncClient {
155156
/// </returns>
156157
Task<ClientResponse<RESTVoid>> ChangePasswordByIdentityAsync(ChangePasswordRequest request);
157158

159+
/// <summary>
160+
/// Changes a user's password using their access token (JWT) instead of the changePasswordId
161+
/// A common use case for this method will be if you want to allow the user to change their own password.
162+
///
163+
/// Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword.
164+
/// This is an asynchronous method.
165+
/// </summary>
166+
/// <param name="encodedJWT"> The encoded JWT (access token).</param>
167+
/// <param name="request"> The change password request that contains all the information used to change the password.</param>
168+
/// <returns>
169+
/// When successful, the response will contain the log of the action. If there was a validation error or any
170+
/// other type of error, this will return the Errors object in the response. Additionally, if FusionAuth could not be
171+
/// contacted because it is down or experiencing a failure, the response will contain an Exception, which could be an
172+
/// IOException.
173+
/// </returns>
174+
Task<ClientResponse<ChangePasswordResponse>> ChangePasswordUsingJWTAsync(string encodedJWT, ChangePasswordRequest request);
175+
158176
/// <summary>
159177
/// Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
160178
/// When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
@@ -5087,6 +5105,7 @@ public interface IFusionAuthSyncClient {
50875105
/// contacted because it is down or experiencing a failure, the response will contain an Exception, which could be an
50885106
/// IOException.
50895107
/// </returns>
5108+
[Obsolete("This method has been renamed to ChangePasswordUsingJWTAsync, use that method instead.")]
50905109
ClientResponse<ChangePasswordResponse> ChangePasswordByJWT(string encodedJWT, ChangePasswordRequest request);
50915110

50925111
/// <summary>
@@ -5103,6 +5122,22 @@ public interface IFusionAuthSyncClient {
51035122
/// </returns>
51045123
ClientResponse<RESTVoid> ChangePasswordByIdentity(ChangePasswordRequest request);
51055124

5125+
/// <summary>
5126+
/// Changes a user's password using their access token (JWT) instead of the changePasswordId
5127+
/// A common use case for this method will be if you want to allow the user to change their own password.
5128+
///
5129+
/// Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword.
5130+
/// </summary>
5131+
/// <param name="encodedJWT"> The encoded JWT (access token).</param>
5132+
/// <param name="request"> The change password request that contains all the information used to change the password.</param>
5133+
/// <returns>
5134+
/// When successful, the response will contain the log of the action. If there was a validation error or any
5135+
/// other type of error, this will return the Errors object in the response. Additionally, if FusionAuth could not be
5136+
/// contacted because it is down or experiencing a failure, the response will contain an Exception, which could be an
5137+
/// IOException.
5138+
/// </returns>
5139+
ClientResponse<ChangePasswordResponse> ChangePasswordUsingJWT(string encodedJWT, ChangePasswordRequest request);
5140+
51065141
/// <summary>
51075142
/// Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
51085143
/// 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)