Unable To Trger Re-authentication With Firebase V4, Javascript
Solution 1:
In version 2.x of Firebase Authentication, the auth state changed handler was only invoked when the user's authentication state changed. So when they signed in or out.
In version 3.x of the Firebase Authentication SDK, the same callback was also invoked for token refreshes. But this lead to developers having problems efficiently updating their UI, since this callback would be invoked even when the authentication state didn't change (even though the token did).
That's why this behavior has indeed changed in v4: the onAuthStateChanged
doesn't fire anymore for token refreshes. There is a separate onIdTokenChanged()
method that does fire in that case: https://firebase.google.com/docs/reference/js/firebase.auth.Auth#onIdTokenChanged
From there:
Adds an observer for changes to the signed-in user's ID token, which includes sign-in, sign-out, and token refresh events. This method has the same behavior as
firebase.auth.Auth#onAuthStateChanged
had prior to 4.0.0.Example:
firebase.auth().onIdTokenChanged(function(user) { if (user) { // User is signed in or token was refreshed. } });
Post a Comment for "Unable To Trger Re-authentication With Firebase V4, Javascript"