Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase 3.0 session persistance

It seems impossible to use session persistence in firebase 3.0.

This was possible in the previous version: https://www.firebase.com/docs/web/guide/login/password.html

authWithPassword() takes an optional third parameter which is an object containing any of the following settings:

remember - String
If not specified - or set to default - sessions are persisted for as long as you have configured in the Login & Auth tab of your App Dashboard. To limit persistence to the lifetime of the current window, set this to sessionOnly. A value of none will not persist authentication data at all and will end authentication as soon as the page is closed.

In version 3.0 there is no mention of the optional 3rd parameter: https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithEmailAndPassword

signInWithEmailAndPassword(email, password)
returns firebase.Promise containing non-null firebase.User

Also, in the new console (https://console.firebase.google.com/) I cannot find the option to change the default persistence.

like image 432
WSas Avatar asked Jun 01 '16 12:06

WSas


2 Answers

It may also be worth mentioning that you need to wait for the auth state to resolve. Per the docs:

The recommended way to get the current user is by setting an observer on the Auth object:

firebase.auth().onAuthStateChanged(function(user) {
  if (user) {
    // User is signed in.
  } else {
    // No user is signed in.
  }
});

Link to the docs here: https://firebase.google.com/docs/auth/web/manage-users

like image 151
braican Avatar answered Oct 21 '22 04:10

braican


In 3.0, users are currently always persisted until signOut() is called (or the user clears local storage).

like image 29
imbanana28321 Avatar answered Oct 21 '22 04:10

imbanana28321