2

In the previous version of Firebase it was possible to control the period for which the token after authentication would be valid. With the new version, we don't have this control. I can not find in the documentation clear explanation of what is happening.

I am using email and password authentication. with sdks 9.0.2 it seems there is no more problems. but I don't know how long my user will be authenticated as such.

I have a singleton FirebaseManager which listen for the state:

  public FirebaseManager() {
    // allow offline capability
    FirebaseDatabase.getInstance().setPersistenceEnabled(true);
    mAuth = FirebaseAuth.getInstance();

    FirebaseAuth.AuthStateListener authStateListener = firebaseAuth -> {
        FirebaseUser user = firebaseAuth.getCurrentUser();
        Log.v(TAG, "authStateListener, user: " + (user == null ? "is null" : user.getUid()));
    };
    mAuth.addAuthStateListener(authStateListener);
}

if i have signed in using:

mAuth.signInWithEmailAndPassword(email, pwd) ... 

in the listener above I'll receive a user. The next time I open my app, the user will still be signed in, and i still receive a user in the listener.

The unclear part is for how long? How firebase handles it? How long until i need to sign-in again? Do I need to sign in again with the same function every time i received a "user == null".

the fact of giving a user == null does not give us a lot of information and I am not sure how to implement that for a long term usage of the app by one user and make sure to keep the user session valid without any need to sign-in again.

drevlav
  • 572
  • 2
  • 6
  • 14

1 Answers1

0

If user is signed in using Email/password Auth then he will remain signed in forever until user logs-out/sign-out of the account.

To signout you can use this. mAuth.signOut();

Sahaj Rana
  • 1,993
  • 4
  • 25
  • 42
  • 1
    did you see something in the documentation which state it? or is it an assumption? I have not being able to find anything in the doc saying that so far. My app will go to production, and i need to be sure. – drevlav Jun 15 '16 at 08:48
  • As i am also working on a project which highly use firebase n its auth for around a year I can say that and you should give it a try and let me know if there is any problem – Sahaj Rana Jun 15 '16 at 09:06
  • The new sdks has been in the market quite recently so no one has a lot of experience on it. I will give it a try but I am still confused concerning the lack of documentation on the matter. – drevlav Jun 15 '16 at 09:24