diff --git a/web/dashboard/src/app/[locale]/register/page.tsx b/web/dashboard/src/app/[locale]/register/page.tsx index 0521061..f375dac 100644 --- a/web/dashboard/src/app/[locale]/register/page.tsx +++ b/web/dashboard/src/app/[locale]/register/page.tsx @@ -58,8 +58,17 @@ function RegisterForm() { const t = useTranslations("auth"); const router = useRouter(); const setAuth = useAuthStore((s) => s.setAuth); + const user = useAuthStore((s) => s.user); + const hasHydrated = useAuthStore((s) => s._hasHydrated); const searchParams = useSearchParams(); + // Already signed in? Don't show the register form — send them into the app. + // Gate on _hasHydrated so a not-yet-rehydrated (null) session isn't misread. + const alreadyAuthed = hasHydrated && !!user?.accessToken; + useEffect(() => { + if (alreadyAuthed) router.replace("/"); + }, [alreadyAuthed, router]); + const [phone, setPhone] = useState(searchParams.get("phone") ?? ""); const [cafeName, setCafeName] = useState(""); const [slug, setSlug] = useState(""); @@ -123,6 +132,14 @@ function RegisterForm() { } }; + if (alreadyAuthed) { + return ( +
+

{t("redirecting")}

+
+ ); + } + return (