diff --git a/packages/webui/components/auth-layout.tsx b/packages/webui/components/auth-layout.tsx index fbb4c2cf..bac4f13e 100644 --- a/packages/webui/components/auth-layout.tsx +++ b/packages/webui/components/auth-layout.tsx @@ -51,9 +51,14 @@ export function AuthLayout({ children }: { children: ReactNode }) { {/* Footer Label */}
-

+ {m.auth_community_cta()} -

+
diff --git a/packages/webui/messages/en.json b/packages/webui/messages/en.json index 641fcf52..70166420 100644 --- a/packages/webui/messages/en.json +++ b/packages/webui/messages/en.json @@ -40,7 +40,8 @@ "no_account_prompt": "Don't have an account? ", "sign_up": "Sign up", "demo_access": "Demo Access:", - "demo_access_instructions": "Use \"foo@bar.com\" as the email and \"foo\" as the password to login (this demo account is read-only).", + "demo_access_instructions": "This demo account is a read-only \"Reviewer\" role user.", + "login_as_demo_user": "Login as demo user", "signup_subtitle": "Start building and organizing your space.", "signup_failed": "Signup failed", diff --git a/packages/webui/messages/zh.json b/packages/webui/messages/zh.json index b022bc22..e5084c7a 100644 --- a/packages/webui/messages/zh.json +++ b/packages/webui/messages/zh.json @@ -40,7 +40,8 @@ "no_account_prompt": "还没有账户?", "sign_up": "注册", "demo_access": "演示访问:", - "demo_access_instructions": "使用 \"foo@bar.com\" 作为邮箱,\"foo\" 作为密码登录(该演示账户为只读)。", + "demo_access_instructions": "该演示账户为只读 \"Reviewer\" 角色用户。", + "login_as_demo_user": "以演示用户登录", "signup_subtitle": "开始构建和整理您的空间。", "signup_failed": "注册失败", diff --git a/packages/webui/routes/login.tsx b/packages/webui/routes/login.tsx index ebabd144..565c3d76 100644 --- a/packages/webui/routes/login.tsx +++ b/packages/webui/routes/login.tsx @@ -9,7 +9,7 @@ import { useAuthStore } from '@/ui/stores/auth' import { zodResolver } from '@hookform/resolvers/zod' import { useQuery } from '@tanstack/react-query' import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router' -import { ArrowRight, Loader2, Lock, LogIn, Mail } from 'lucide-react' +import { ArrowRight, Loader2, Lock, LogIn, Mail, UserCheck } from 'lucide-react' import { useEffect, useState } from 'react' import { useForm } from 'react-hook-form' import { z } from 'zod' @@ -27,6 +27,7 @@ function LoginPage() { const setUser = useAuthStore((state) => state.setUser) const [error, setError] = useState(null) const [loading, setLoading] = useState(false) + const [demoLoading, setDemoLoading] = useState(false) const { data: signupInfo, isLoading: isSignupInfoLoading } = useQuery({ queryKey: ['/signup-info'], @@ -69,6 +70,30 @@ function LoginPage() { } } + const onDemoLogin = async () => { + setDemoLoading(true) + setError(null) + form.clearErrors() + form.setValue('email', 'foo@bar.com') + form.setValue('password', 'foo') + + const { data: session, error: signInError } = await signIn.email({ + email: 'foo@bar.com', + password: 'foo', + }) + + setDemoLoading(false) + if (signInError) { + setError(signInError.message || m.invalid_credentials()) + return + } + + if (session) { + setUser(session.user) + navigate({ to: '/' }) + } + } + if (isSignupInfoLoading) { return (
@@ -89,14 +114,6 @@ function LoginPage() {

{m.login_subtitle()}

- {isDemoEnv && ( -
-

- {m.demo_access()} {m.demo_access_instructions()} -

-
- )} - {error && (
{error} @@ -155,7 +172,7 @@ function LoginPage() { + {isDemoEnv && ( +
+
+
+ +
+
+ + {m.or()} + +
+
+ + + +
+

+ {m.demo_access()} {m.demo_access_instructions()} +

+
+
+ )} +
{m.no_account_prompt()}