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
The goal: once you login on one site, you are logged in on all
We should have only one login page at lux.services/login, all login buttons should link to that one.
Using cross domain communication set session cookies on all lux domains after user logs in successfully
<!-- parent.html --><!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"><title>Parent Frame</title></head><body><h1>Parent Frame</h1><iframeid="childFrame" src="https://child.example.com"></iframe><script>// Simulate obtaining the JWT tokenconstjwtToken="sample_jwt_token";// Send the JWT token to the child framewindow.addEventListener('load',function(){constchildFrame=document.getElementById('childFrame');childFrame.contentWindow.postMessage(jwtToken,'https://child.example.com');});</script></body></html>
<!-- child.html --><!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"><title>Child Frame</title></head><body><h1>Child Frame</h1><script>// Listen for messages from the parent framewindow.addEventListener('message',function(event){// Check if the message is from a trusted originif(event.origin==='https://parent.example.com'){// Set the JWT token received from the parent frameconstjwtToken=event.data;localStorage.setItem('token',jwtToken);console.log("JWT token set:",jwtToken);}else{console.warn("Received message from untrusted origin:",event.origin);}});</script></body></html>
if custom token is set in localstorage/cookie use it, otherwise they are logged out
import{getAuth,signInWithCustomToken}from"firebase/auth";constauth=getAuth();signInWithCustomToken(auth,token).then((userCredential)=>{// Signed inconstuser=userCredential.user;// ...}).catch((error)=>{consterrorCode=error.code;consterrorMessage=error.message;// ...});
The text was updated successfully, but these errors were encountered:
The goal: once you login on one site, you are logged in on all
The text was updated successfully, but these errors were encountered: