@@ -267,16 +267,29 @@ this.tokenService.validateToken().subscribe(
267
267
` ` `
268
268
269
269
# ## .updatePassword()
270
- Updates the password for the logged in user.
271
- ` updatePassword({password: string, passwordConfirmation: string, passwordCurrent: string, userType? : string, resetPasswordToken? : string}): Observable< Response> `
270
+ Updates the password for the logged in user. Note that there are two main flows that this is used for -
271
+ a user changing their password while they are already logged in and a " forgot password" flow where the user is doing an
272
+ update via the link in a reset password email.
273
+
274
+ For a normal password update, you need to send the new password twice, for confirmation and you may also have to send
275
+ the current password for extra security. The setting " check_current_password_before_update" in the Devise Token Auth
276
+ library is used to control if the current password is required or not.
277
+
278
+ For the reset password flow where the user is not logged in, this library does not currently support a password update
279
+ via this updatePassword call. This is because an update password call in that scenario requires the auth headers to be
280
+ created from the query strings in the redirected URL sent from the server once the email reset link is clicked.
281
+ You will need to provide this functionality yourself and use the .request () method below to send a PUT to the password
282
+ endpoint with the correct headers. Your code should copy over the client_id, expiry, token and uid query string
283
+ values from the redirected URL into their respective header properties.
284
+
285
+ ` updatePassword({password: string, passwordConfirmation: string, passwordCurrent: string, userType? : string}): Observable< Response> `
272
286
273
287
# ### Example:
274
288
` ` ` javascript
275
289
this.tokenService.updatePassword({
276
290
password: ' newPassword' ,
277
291
passwordConfirmation: ' newPassword' ,
278
292
passwordCurrent: ' oldPassword' ,
279
- resetPasswordToken: ' resetPasswordToken' ,
280
293
}).subscribe(
281
294
res => console.log(res),
282
295
error => console.log(error)
0 commit comments