user6650650
user6650650

Reputation:

Firebase user auth state logic

After signing a user in with Firebase, for how long will he stay as signed-in ? I mean for example , what happens when application is not visible or destroyed ? Does firebase automaticly log that user out? Or do I need to write that logic myself?

Upvotes: 0

Views: 377

Answers (2)

appersiano
appersiano

Reputation: 2770

From official documentation https://firebase.google.com/docs/auth/users#the_current_user

When a user signs up or signs in, that user becomes the current user of the Auth instance. The Firebase Auth instance persists the user's state, so that refreshing the page (in a browser) or restarting the application doesn't lose the user's information.

When the user signs out, the Auth instance stops keeping a reference to the User object and no longer persists its state; there is no current user. However, the user instance continues to be completely functional: if you keep a reference to it, you can still access and update the user's data.

So you have to manually sign out the user by using FirebaseAuth.getInstance().signOut() method.

This implementation is very smart because this way you do not have to manage user "session" but you have only to implemente signout where needed!

Upvotes: 1

T.S
T.S

Reputation: 951

You need to write that logic yourself, just write:

FirebaseAuth.getInstance().signOut();

Upvotes: 0

Related Questions