Skip to content

Commit 47fcc38

Browse files
Merge branch 'master' of github.com:neroniaky/angular2-token
2 parents e9cf34b + bf349d6 commit 47fcc38

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ npm-debug.log
1414
.DS_Store
1515
**/.DS_Store
1616

17-
# VSCode config
17+
# Ignore VSCode Config
1818
.vscode
1919

20+
# JetBrains
21+
.idea
22+
2023
# Yarn
2124
yarn-error.log

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,29 @@ this.tokenService.validateToken().subscribe(
267267
```
268268
269269
### .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>`
272286
273287
#### Example:
274288
```javascript
275289
this.tokenService.updatePassword({
276290
password: 'newPassword',
277291
passwordConfirmation: 'newPassword',
278292
passwordCurrent: 'oldPassword',
279-
resetPasswordToken: 'resetPasswordToken',
280293
}).subscribe(
281294
res => console.log(res),
282295
error => console.log(error)

0 commit comments

Comments
 (0)