completionId: cgen-9afabb5cf35141549055f29c2fabec02
cgen-9afabb5cf35141549055f29c2fabec02
This commit is contained in:
parent
2bf5324cc3
commit
067d2e0bf5
1 changed files with 12 additions and 3 deletions
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue