1

I am new to token based authentication and doing the following:

  1. Authenticate the user by email and password,
  2. get a token back from backend,
  3. store the token in local storage,
  4. check to see if a token is present. If yes then user is logged in.

What what I want to achieve is that if the user changes his password then the client should prompt for fresh login. How can this be done?

Roope Hakulinen
  • 7,326
  • 4
  • 43
  • 66
krv
  • 2,830
  • 7
  • 40
  • 79

1 Answers1

0

This depends whether you are using Refresh Tokens or not as user Gopinath Shiva describes in his answer to question about somewhat same domain.

If you use Refresh Tokens, then

When the user changes his password, change the refresh token of the user. Hence the remaining session will get logged out soon.

If you don't, then

When the user changes his password, note the change password time in the user db, so when the change password time is greater than the token creation time, then token is not valid. Hence the remaining session will get logged out soon.

Community
  • 1
  • 1
Roope Hakulinen
  • 7,326
  • 4
  • 43
  • 66