Skip to content

Commit 14bf164

Browse files
Merge pull request #43 from FusionAuth/lyle/ENG-2742/change-password-using-jwt
changePasswordUsingJWT
2 parents e560943 + b7e2295 commit 14bf164

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/fusionauth/fusionauth_client.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def change_password(change_password_id, request)
143143
# @param encoded_jwt [string] The encoded JWT (access token).
144144
# @param request [OpenStruct, Hash] The change password request that contains all the information used to change the password.
145145
# @return [FusionAuth::ClientResponse] The ClientResponse object.
146+
# @deprecated This method has been renamed to change_password_using_jwt, use that method instead.
146147
def change_password_by_jwt(encoded_jwt, request)
147148
startAnonymous.uri('/api/user/change-password')
148149
.authorization('Bearer ' + encoded_jwt)
@@ -165,6 +166,23 @@ def change_password_by_identity(request)
165166
.go
166167
end
167168

169+
#
170+
# Changes a user's password using their access token (JWT) instead of the changePasswordId
171+
# A common use case for this method will be if you want to allow the user to change their own password.
172+
#
173+
# Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword.
174+
#
175+
# @param encoded_jwt [string] The encoded JWT (access token).
176+
# @param request [OpenStruct, Hash] The change password request that contains all the information used to change the password.
177+
# @return [FusionAuth::ClientResponse] The ClientResponse object.
178+
def change_password_using_jwt(encoded_jwt, request)
179+
startAnonymous.uri('/api/user/change-password')
180+
.authorization('Bearer ' + encoded_jwt)
181+
.body_handler(FusionAuth::JSONBodyHandler.new(request))
182+
.post
183+
.go
184+
end
185+
168186
#
169187
# Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
170188
# 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)