Firebase 3.0 Session Resistance

It seems impossible to use session persistence in firebase 3.0.

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

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

remember - String
If you don’t specify - or set a default value - the sessions are saved until you configure the Login and Out tab of your application panel. To limit constancy to the lifetime of the current window, set sessionOnly for this. A value of none will not migrate authentication data and complete authentication as soon as possible when the page is closed.

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

signInWithEmailAndPassword (email, password)
returns firebase.Promise containing a nonzero firebase.User

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

+5
source share
3 answers

You can also note that you need to wait until auth status resolves. In documents:

The recommended way to get the current user is to set the 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

+5
source

In 3.0, users are now always saved until the signOut () call (or the user clears the local storage).

+3
source

Firebase Auth JS SDK now supports sessionOnly persistence. For more on this, check out https://firebase.google.com/support/release-notes/js#4.2.0 and https://firebase.google.com/docs/auth/web/auth-state-persistence

Now you can specify or transfer the state of Auth state before or after login. For your case, you can specify persistence only for the session as follows: firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION)

+1
source

All Articles