You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in the spirit of 'https://firebase.google.com/docs/auth/web/custom-dependencies' and 'firebase/firebase-js-sdk#4946' I am now deferring the loading of 'signInWithPopup' iFrame ... which pagespeed insights complains about. This is done by swapping getAuth(app) for initializeAuth(app,..) and then contextually loading the 'browserPopupRedirectResolver' method and passing as a third parameter to 'signInWithPopup' in both google and twitter login functions
Copy file name to clipboardExpand all lines: src/lib/Login/loginFunctions.js
+9-3
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,9 @@ export async function magicLinkToEmail(EMAIL) {
42
42
// TODO: nov29.2022 : google login didnt work with 'signInWithRedirect' logic, so assuming the same for twitter login .. getting rid of the if-else logic and keeping only the 'signInWithPopup' logic
// This gives you a the Twitter OAuth 1.0 Access Token and Secret.
79
82
// You can use these server side with your app's credentials to access the Twitter API.
@@ -101,11 +104,13 @@ export async function TwitterLogin() {
101
104
// TODO: nov29.2022 noticed that 'signinWithRedirect' logic did not sign me in ... furthermore 'signInWithPopup' worked perfectly on both the PWA and on the mobile version of the website ... It appears firebase has consolidated the two??
102
105
exportasyncfunctionGoogleLogin(){
103
106
// const auth = await import("$lib/firebase");
107
+
104
108
const{
105
109
GoogleAuthProvider,
106
110
// setPersistence,
107
111
// browserSessionPersistence,
108
112
// inMemoryPersistence,
113
+
browserPopupRedirectResolver,
109
114
}=awaitimport("firebase/auth");
110
115
111
116
// if (get(lessThan768)) {
@@ -134,7 +139,8 @@ export async function GoogleLogin() {
Copy file name to clipboardExpand all lines: src/lib/firebase.js
+18-2
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,13 @@
1
1
import*asNVfrom"$env/static/public";
2
2
import{initializeApp}from"firebase/app";
3
-
import{getAuth}from"firebase/auth";
3
+
// import { getAuth } from "firebase/auth";
4
+
5
+
import{
6
+
initializeAuth,
7
+
indexedDBLocalPersistence,
8
+
browserLocalPersistence,
9
+
browserSessionPersistence,
10
+
}from"firebase/auth";
4
11
5
12
// import { getFirestore } from "firebase/firestore/lite";
6
13
@@ -14,7 +21,16 @@ const firebaseConfig = {
14
21
};
15
22
16
23
exportconstapp=initializeApp(firebaseConfig);
17
-
exportconstauth=getAuth(app);
24
+
// export const auth = getAuth(app);
25
+
26
+
exportconstauth=initializeAuth(app,{
27
+
persistence: [
28
+
indexedDBLocalPersistence,
29
+
browserLocalPersistence,
30
+
browserSessionPersistence,
31
+
],
32
+
});
33
+
18
34
// this is used when website is mounted to persist login state ... maybe import when login clicked instead??
19
35
20
36
// idea: import getAuth on page load IF visitor as logged in before ... e.g. can set a localstorage variable ("previouslyLoggedIn") inside the logged in logic (not here)
0 commit comments