fix(web): 注册页补充已登录重定向守卫,与登录页 / classic 主题保持一致 (#5908) - #5910
Conversation
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 QuantumNous#5908
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe sign-up route in the default theme adds a ChangesSign-up authentication guard
Estimated code review effort: 1 (Trivial) | ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…codes * origin/main: (180 commits) fix(billing): extend quantity validation and saturating conversions to remaining paths fix(billing): validate quantity parameters and harden quota calculations Fix/build date dns error (QuantumNous#5945) fix: avoid stale stream writes after client disconnect (QuantumNous#5710) feat(group): enhance group ratio editor with improved visibility rules and JSON parsing feat: optimize legacy top-up warning banner copy (QuantumNous#5851) (QuantumNous#5855) fix(web): redirect authenticated users away from sign-up page (QuantumNous#5910) feat(ssrf): implement SSRF protection in HTTP clients and validation functions feat(user): better messages for redeem failures fix(html): 修复 Shadow DOM 隔离渲染下深浅色模式无法自动切换的问题 (QuantumNous#5890) fix(web): sync home iframe theme and language (QuantumNous#5917) fix: 任务差额结算后 quota 和阿里视频时长优化 (QuantumNous#5923) fix(web): refine mobile user cards test(user): cover self-service password update guard feat(session): support opt-in Secure session cookies fix(auth): allow read-only access for non-disabled tokens fix(user): harden account email and password handling fix: align dynamic pricing style with log details dialog sections fix(channels): show field passthrough controls for Codex (QuantumNous#5902) fix(user): trim whitespace from username and validate input ... # Conflicts: # controller/redemption.go # controller/user.go # model/option.go # model/redemption.go # model/user.go # web/default/src/features/auth/api.ts # web/default/src/features/redemption-codes/api.ts # web/default/src/features/redemption-codes/components/redemptions-provider.tsx # web/default/src/features/redemption-codes/components/redemptions-table.tsx # web/default/src/features/redemption-codes/constants.ts # web/default/src/hooks/use-sidebar-data.ts # web/default/src/i18n/static-keys.ts # web/default/src/routes/__root.tsx
…mNous#5910) 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 QuantumNous#5908 Co-authored-by: 贺. <kuang@M1.local>
…mNous#5910) 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 QuantumNous#5908 Co-authored-by: 贺. <kuang@M1.local>
…mNous#5910) 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 QuantumNous#5908 Co-authored-by: 贺. <kuang@M1.local>
…mNous#5910) 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 QuantumNous#5908 Co-authored-by: 贺. <kuang@M1.local>
…mNous#5910) 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 QuantumNous#5908 Co-authored-by: 贺. <kuang@M1.local> (cherry picked from commit 3a876d6)
…mNous#5910) 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 QuantumNous#5908 Co-authored-by: 贺. <kuang@M1.local>
…mNous#5910) 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 QuantumNous#5908 Co-authored-by: 贺. <kuang@M1.local>
…mNous#5910) 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 QuantumNous#5908 Co-authored-by: 贺. <kuang@M1.local>
📝 变更描述 / Description
default 主题下,登录页
/sign-in的 route 已在beforeLoad中做了"已登录则重定向到/dashboard"的守卫,但注册页/sign-up(以及其别名/register,后者仅throw redirect到/sign-up)没有等价守卫,导致已登录用户访问注册页时停在注册表单,而非进入主界面。本 PR 在
sign-up.tsx的 route 增加与sign-in.tsx一致的beforeLoad守卫:沿用同一useAuthStore判断登录态,已登录时throw redirect({ to: '/dashboard' })。守卫加在实际渲染注册页的/sign-up,因此/register与/sign-up两个入口都被覆盖。该行为与旧 classic 主题web/classic/src/helpers/auth.jsx中AuthRedirect对/register的处理一致。说明:这不是 rc.13→rc.16 之间的代码回归(两个 tag 的该路由文件除格式化外无功能差异,
/sign-up守卫在 default 前端自 v1.0 起从未存在),因此作为"行为一致性补齐"提交,归类为 Refactor / 一致性修复而非 Bug。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
sign-up.tsx一处,逻辑复用现有sign-in.tsx模式,无无关改动。bun run typecheck通过;bunx oxlint对本文件零 error;format:check通过。📸 运行证明 / Proof of Work
web/default/src/routes/(auth)/sign-in.tsx:32-41已有等价守卫(跳/dashboard)。sign-up.tsx):新增redirect/useAuthStoreimport,并在 route 增加beforeLoad:bun run typecheck(tsgo -b)通过;bunx oxlint -c .oxlintrc.json "src/routes/(auth)/sign-up.tsx"零 error;format 检查通过。Summary by CodeRabbit