2

I have a functioning electron app and I'd like to load a url from another site (created by me for the app). The trouble I'm having is persisting the login when I loadURL from the main process in Electron.

I am successfully maintaining auth state status between various local html files within electron (using separate JS files) so I am assuming the issue is related to loadURL vs loadFILE on a new html file. Currently I'm testing using a localhost port for the other URL (the one not reading Auth State).

I use the following code to detect the state change:

let extConfig = {
  apiKey: "myKEY",
  authDomain: "fcf-appdestination.com",
  databaseURL: "https://fcf-appdestination.com",
  projectId: "fcf-app",
  storageBucket: "fcf-app-bucket",
  appId: "1:APPID",
}
const fbApp = firebase.initializeApp(extConfig);

firebase.auth().onAuthStateChanged((user) => {
    if(user){
      currentUser = user.uid
    } 
  })

What's frustrating is when I navigate to the prior working page (via a button triggering a loadFile event in the main process in Electron) the auth state persists and the user is logged in.

Am I not able to persist the firebase auth state in the way I'd like?

Thank you,

sychordCoder
  • 230
  • 3
  • 14

1 Answers1

0

I found the answer here: Is there any way to keep a person authenticated with firebase across subdomains

You need to use a server function to create a custom token as an admin and send the token to the subdomain to use for login.

sychordCoder
  • 230
  • 3
  • 14