Skip to content

Commit b4976c1

Browse files
Revert: Move VueFire persistence configuration to initialization (#5614) (#5729)
## Summary This reverts PR #5614 which moved VueFire persistence configuration to initialization. ## Reason for Revert It breaks Google SSO login with error: ``` useErrorHandling.ts:12 FirebaseError: Firebase: Error (auth/argument-error). at createErrorInternal (index-c92d61ad.js:506:41) at _assert (index-c92d61ad.js:512:15) at _withDefaultResolver (index-c92d61ad.js:9237:5) at signInWithPopup (index-c92d61ad.js:9457:30) at executeAuthAction.createCustomer (firebaseAuthStore.ts:263:25) at executeAuthAction (firebaseAuthStore.ts:223:28) at Proxy.loginWithGoogle (firebaseAuthStore.ts:262:5) at Proxy.wrappedAction (pinia.mjs:1405:26) at useFirebaseAuthActions.ts:104:28 at Object.signInWithGoogle (useErrorHandling.ts:39:22) ``` ## Changes - Reverts commit ea4e57b "Move VueFire persistence configuration to initialization (#5614)" - Restores previous Firebase auth persistence behavior ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5729-Revert-Move-VueFire-persistence-configuration-to-initialization-5614-2776d73d3650814c9b80d9c67c852874) by [Unito](https://www.unito.io)
1 parent 1611c7a commit b4976c1

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

src/main.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@ import { definePreset } from '@primevue/themes'
22
import Aura from '@primevue/themes/aura'
33
import * as Sentry from '@sentry/vue'
44
import { initializeApp } from 'firebase/app'
5-
import {
6-
browserLocalPersistence,
7-
browserSessionPersistence,
8-
indexedDBLocalPersistence
9-
} from 'firebase/auth'
105
import { createPinia } from 'pinia'
116
import 'primeicons/primeicons.css'
127
import PrimeVue from 'primevue/config'
138
import ConfirmationService from 'primevue/confirmationservice'
149
import ToastService from 'primevue/toastservice'
1510
import Tooltip from 'primevue/tooltip'
1611
import { createApp } from 'vue'
17-
import { VueFire, VueFireAuthWithDependencies } from 'vuefire'
12+
import { VueFire, VueFireAuth } from 'vuefire'
1813

1914
import { FIREBASE_CONFIG } from '@/config/firebase'
2015
import '@/lib/litegraph/public/css/litegraph.css'
@@ -71,18 +66,6 @@ app
7166
.use(i18n)
7267
.use(VueFire, {
7368
firebaseApp,
74-
modules: [
75-
// Configure Firebase Auth persistence: localStorage first, IndexedDB last.
76-
// Localstorage is preferred to IndexedDB for mobile Safari compatibility.
77-
VueFireAuthWithDependencies({
78-
dependencies: {
79-
persistence: [
80-
browserLocalPersistence,
81-
browserSessionPersistence,
82-
indexedDBLocalPersistence
83-
]
84-
}
85-
})
86-
]
69+
modules: [VueFireAuth()]
8770
})
8871
.mount('#vue-app')

src/stores/firebaseAuthStore.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {
66
GoogleAuthProvider,
77
type User,
88
type UserCredential,
9+
browserLocalPersistence,
910
createUserWithEmailAndPassword,
1011
deleteUser,
1112
onAuthStateChanged,
1213
sendPasswordResetEmail,
14+
setPersistence,
1315
signInWithEmailAndPassword,
1416
signInWithPopup,
1517
signOut,
@@ -80,6 +82,8 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => {
8082
// Retrieves the Firebase Auth instance. Returns `null` on the server.
8183
// When using this function on the client in TypeScript, you can force the type with `useFirebaseAuth()!`.
8284
const auth = useFirebaseAuth()!
85+
// Set persistence to localStorage (works in both browser and Electron)
86+
void setPersistence(auth, browserLocalPersistence)
8387

8488
onAuthStateChanged(auth, (user) => {
8589
currentUser.value = user

tests-ui/tests/store/firebaseAuthStore.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ describe('useFirebaseAuthStore', () => {
150150
expect(store.loading).toBe(false)
151151
})
152152

153+
it('should set persistence to local storage on initialization', () => {
154+
expect(firebaseAuth.setPersistence).toHaveBeenCalledWith(
155+
mockAuth,
156+
firebaseAuth.browserLocalPersistence
157+
)
158+
})
159+
153160
it('should properly clean up error state between operations', async () => {
154161
// First, cause an error
155162
const mockError = new Error('Invalid password')

0 commit comments

Comments
 (0)