completionId: cgen-9afabb5cf35141549055f29c2fabec02

cgen-9afabb5cf35141549055f29c2fabec02
This commit is contained in:
Builder.io 2025-11-13 03:42:40 +00:00
parent 2bf5324cc3
commit 067d2e0bf5

View file

@ -17,18 +17,27 @@ export default function StaffLogin() {
const [isSigningIn, setIsSigningIn] = useState(false);
const [error, setError] = useState<string | null>(null);
// Redirect if already authenticated and has @aethex.dev email
// Redirect if already authenticated and has @aethex.dev email (primary or linked)
useEffect(() => {
if (!loading && user && profile) {
const email = user.email || profile.email || "";
if (email.endsWith("@aethex.dev")) {
const hasDevEmail =
email.endsWith("@aethex.dev") ||
(profile as any)?.is_dev_account ||
user.identities?.some((identity: any) =>
identity.identity_data?.email?.endsWith("@aethex.dev"),
);
if (hasDevEmail) {
toastInfo({
title: "Already logged in",
description: "Redirecting to staff dashboard...",
});
navigate("/staff/dashboard", { replace: true });
} else {
setError("Only @aethex.dev email addresses are allowed");
setError(
"Only @aethex.dev email addresses (or linked accounts) are allowed",
);
}
}
}, [user, profile, loading, navigate, toastInfo]);