Firebase ID Token change when password reset

Viewed 1239

I use Firebase ID Tokens to show data on my site when someone is logging in. I save the token in a cookie on the client side and when the client accesses the website it takes the token from his cookie file and sends it to my backend server.

I would like to remove all ID Tokens when a password is reset so all the logged in clients using that username and password would disconnect.

Is this option valid? If so how can you do it? They don't seem to mention it in their docs.

1 Answers

When a user's password is reset, changed or the associated email is updated, Firebase Auth will invalidate all existing sessions for that user for security reasons. This effectively invalidates that user's ID token from the perspective of Firebase Auth backend. The refresh token will also not be able to issue a new ID token.

Also I agree with Scott. You should use currentUser.getIdToken() to get the ID token instead of storing it yourself. This API takes care of refreshing the ID token for you when it expires.

Related