I was wondering how to persist the authentication state with firebase. What I am doing is trying to set the persistence state and I do it like this:
login.addEventListener('click', function (e) {
e.preventDefault();
var email = emailInput.value;
var password = passwordInput.value;
firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL)
.then(function() {
auth.signInWithEmailAndPassword(email, password)
.then(function (user) {
})
.catch(function (error) {
alert(error);
});
})
});
The problem is that when I refresh my web app the session appears not to be persisted. It redirects the user back to the login screen which is not the desired out put at all. The desired output would the session for the user is saved and the user is able to go through the app without having the issue being forced to login again.
I am following the firebase documentation:
https://firebase.google.com/docs/auth/web/auth-state-persistence