From 3a876d6f31b5189101364889efe2ac95db0c0960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=BEL?= Date: Mon, 6 Jul 2026 14:57:36 +0800 Subject: [PATCH] fix(web): redirect authenticated users away from sign-up page (#5910) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sign-in route already redirects logged-in users to /dashboard in its beforeLoad guard, but the sign-up route (and its /register alias) had no such guard, leaving authenticated users on the registration form. This mirrors the classic theme's AuthRedirect behavior. Add an equivalent beforeLoad guard using the same useAuthStore, redirecting to /dashboard for consistency with the sign-in route. Closes #5908 Co-authored-by: 贺. --- web/default/src/routes/(auth)/sign-up.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/default/src/routes/(auth)/sign-up.tsx b/web/default/src/routes/(auth)/sign-up.tsx index f14db208..9d6c1bc4 100644 --- a/web/default/src/routes/(auth)/sign-up.tsx +++ b/web/default/src/routes/(auth)/sign-up.tsx @@ -16,10 +16,19 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ -import { createFileRoute } from '@tanstack/react-router' +import { createFileRoute, redirect } from '@tanstack/react-router' import { SignUp } from '@/features/auth/sign-up' +import { useAuthStore } from '@/stores/auth-store' export const Route = createFileRoute('/(auth)/sign-up')({ component: SignUp, + beforeLoad: async () => { + const { auth } = useAuthStore.getState() + + // 如果已经有用户信息,说明已登录,注册页对其无意义,跳转到 dashboard + if (auth.user) { + throw redirect({ to: '/dashboard' }) + } + }, })