My app has basic authentication form for registered admin user. In the SignIn form Email and pass are required and optionally 'Remember me' could be checked. Initially I set Auth persist to 'session' or 'local' depending on user choice, like showed in the docs.
firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION) // or .LOCAL
.then(function() {
firebase.auth().signInWithEmailAndPassword(email, password) ...
I have logout button calling firebase.auth().signOut()
. It seems to logout the user, and redirects to login screen, but if page is reloaded, user is again logged in, without going through the SignIn form.
I thought about adding setPersistence(firebase.auth.Auth.Persistence.NONE)
to the logout logic, but (at least in the docs) it needs user credentials to signInWithEmailAndPassword
. Problem is at this point if the account is previously persisted, and loged in, user didn't leave email
and password
. Well, at least the password.
Is my approach fundamentally wrong, or do I need to clear local storage in some other way? Or maybe set persistUser to 'none' without calling signInWithEmailAndPassword
again?