Welcome
Currently working on a web application using Quasar/Vue.js and Firebase that requires user authentication.
My Objective
I am aiming to implement a common feature - keeping users logged in even after they have closed the browser or tab.
Potential Solutions
While I am aware of the option to utilize localStorage or cookies for managing user authentication state, I am interested in exploring if Firebase auth can handle this task for me.
After reviewing the documentation at https://firebase.google.com/docs/auth/web/auth-state-persistence, I noted the code snippet provided:
firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL)
.then(function() {
// The new sign-in will be persisted with session persistence.
return firebase.auth().signInWithEmailAndPassword(email, password);
})
.catch(function(error) {
// Handle any errors here.
var errorCode = error.code;
var errorMessage = error.message;
});
However, I am uncertain about where to integrate this code snippet. Should it be placed within:
- The
onAuthStatechanged
listener? - The App.vue (root Vue) instance?
- Another location entirely?
Any guidance on this matter would be greatly appreciated. Thank you.