samuelgozi / firebase-auth-lite

A lightweight firebase auth alternative for the browser
MIT License
119 stars 19 forks source link

feat: Developer can now force the IdToken Refresh #54

Closed ocruzv closed 3 years ago

ocruzv commented 4 years ago

Sometimes we need to force the IdToken Refresh and we just realized that wasn't possible. Just added a parameter to the refreshIdToken() function to force the refresh, even if the token is still valid.

Our use case:

When a new user is created, we trigger a firebase callable function to set custom claims in the firebase auth user, after setting these claims we need to refresh the idToken to start making requests with these custom claims set.

That's possible with the official library with auth.currentUser.getIdToken(true), so, with firebase-auth-lite we can just do auth.refreshIdToken(true).

There's no breaking changes.

samuelgozi commented 4 years ago

Thank you for the contribution. Can you please add a test case for this? If you have any trouble, please let me know and ill add this myself.

ocruzv commented 3 years ago

Sorry for doing this so slow, I have added the test case!

samuelgozi commented 3 years ago

Thank you for taking the time to do it in the first place!

samuelgozi commented 3 years ago

The changes in this PR are available in version 0.8.8