Reputation: 117
I tried to persist user's logging in from after user logged in to before user logged out but 1 hour after logging in user using Firebase, problem that firebase.auth().currentUser
became null
occurred. in this situation How do I keep the user logged in?
Upvotes: 1
Views: 282
Reputation: 83058
How do I keep the user logged in?
As explained in the documentation on Authentication State Persistence, with the JS SDK, by default a signed in user is indefinitely persisted until explicit sign out. So normally you should not do anything to have this persistence.
Concretely, as explained here, when the access token expires after one hour, the SDK uses the refresh token behind the scene to get a new valid set of tokens.
If you have a specific reason to manage this persistence yourself instead of taking advantage of the standard mechanism, please update your question accordingly.
Upvotes: 3