[API Node] Set auth persistence in local stoarge (#3514)

This commit is contained in:
Christian Byrne
2025-04-19 11:15:07 +08:00
committed by GitHub
parent fbc6665ff4
commit 9cd11261f9
2 changed files with 15 additions and 1 deletions

View File

@@ -4,8 +4,10 @@ import {
GoogleAuthProvider,
type User,
type UserCredential,
browserLocalPersistence,
createUserWithEmailAndPassword,
onAuthStateChanged,
setPersistence,
signInWithEmailAndPassword,
signInWithPopup,
signOut
@@ -33,6 +35,9 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
// Get auth from VueFire and listen for auth state changes
const auth = useFirebaseAuth()
if (auth) {
// Set persistence to localStorage (works in both browser and Electron)
void setPersistence(auth, browserLocalPersistence)
onAuthStateChanged(auth, (user) => {
currentUser.value = user
isInitialized.value = true