File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,25 @@ export class FusionAuthClient {
158158 . go ( ) ;
159159 }
160160
161+ /**
162+ * Changes a user's password using their access token (JWT) instead of the changePasswordId
163+ * A common use case for this method will be if you want to allow the user to change their own password.
164+ *
165+ * Remember to send refreshToken in the request body if you want to get a new refresh token when login using the returned oneTimePassword.
166+ *
167+ * @param {string } encodedJWT The encoded JWT (access token).
168+ * @param {ChangePasswordRequest } request The change password request that contains all the information used to change the password.
169+ * @returns {Promise<ClientResponse<ChangePasswordResponse>> }
170+ */
171+ changePasswordByJWT ( encodedJWT : string , request : ChangePasswordRequest ) : Promise < ClientResponse < ChangePasswordResponse > > {
172+ return this . startAnonymous < ChangePasswordResponse , Errors > ( )
173+ . withUri ( '/api/user/change-password' )
174+ . withAuthorization ( 'Bearer ' + encodedJWT )
175+ . withJSONBody ( request )
176+ . withMethod ( "POST" )
177+ . go ( ) ;
178+ }
179+
161180 /**
162181 * Changes a user's password using their identity (loginId and password). Using a loginId instead of the changePasswordId
163182 * bypasses the email verification and allows a password to be changed directly without first calling the #forgotPassword
You can’t perform that action at this time.
0 commit comments