feature/IO-3255-simplified-parts-management -Checkpoint

This commit is contained in:
Dave Richer
2025-07-21 15:28:03 -04:00
parent dfa457e3c6
commit 0ac9bbd97c

View File

@@ -42,16 +42,19 @@ export function SignInComponent({ emailSignInStart, currentUser, signInError, se
}
}, [currentUser, redirect, navigate]);
// Add event listener for seamless login
useEffect(() => {
const handleSeamlessLogin = (event) => {
const { email, password, origin: requestOrigin } = event.detail || {};
console.log("Received message event:", event); // Log the received message event
if (event.data?.type !== "seamlessLoginRequest") return; // Filter to only handle relevant messages
console.log("Received seamless login request:", event.data);
const { email, password } = event.data || {}; // Use event.data instead of event.detail
const requestOrigin = event.origin; // Use event.origin automatically
// Validate input
// Validate input (rest of your code remains the same)
if (!email || !password) {
window.parent.postMessage(
{ type: "seamlessLoginResponse", status: "error", message: "Email and password are required" },
requestOrigin || "*" // Use specific origin for security if known
requestOrigin || "*"
);
return;
}
@@ -69,12 +72,10 @@ export function SignInComponent({ emailSignInStart, currentUser, signInError, se
window.parent.postMessage({ type: "seamlessLoginResponse", status: "login_attempted" }, requestOrigin || "*");
};
// Add event listener for custom seamless login event
window.addEventListener("seamlessLoginRequest", handleSeamlessLogin);
window.addEventListener("message", handleSeamlessLogin); // Listen for "message"
// Cleanup to remove the event listener on unmount
return () => {
window.removeEventListener("seamlessLoginRequest", handleSeamlessLogin);
window.removeEventListener("message", handleSeamlessLogin);
};
}, [emailSignInStart, currentUser, navigate, redirect]);