diff --git a/lib/fusionauth/fusionauth_client.rb b/lib/fusionauth/fusionauth_client.rb index 923384b..691a1a4 100644 --- a/lib/fusionauth/fusionauth_client.rb +++ b/lib/fusionauth/fusionauth_client.rb @@ -134,6 +134,23 @@ def change_password(change_password_id, request) .go end + # + # 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 encoded_jwt [string] The encoded JWT (access token). + # @param request [OpenStruct, Hash] The change password request that contains all the information used to change the password. + # @return [FusionAuth::ClientResponse] The ClientResponse object. + def change_password_by_jwt(encoded_jwt, request) + startAnonymous.uri('/api/user/change-password') + .authorization('Bearer ' + encoded_jwt) + .body_handler(FusionAuth::JSONBodyHandler.new(request)) + .post + .go + end + # # Changes a user's password using their identity (loginId and password). Using a loginId instead of the changePasswordId # bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword