This commit is contained in:
parent
88e1ccf4a9
commit
b289121bf8
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { useTranslation } from 'next-i18next'
|
||||||
import { Brand } from "@/components/ui/brand"
|
import { Brand } from "@/components/ui/brand"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Label } from "@/components/ui/label"
|
import { Label } from "@/components/ui/label"
|
||||||
|
|
@ -19,6 +20,8 @@ export default async function Login({
|
||||||
}: {
|
}: {
|
||||||
searchParams: { message: string }
|
searchParams: { message: string }
|
||||||
}) {
|
}) {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const cookieStore = cookies()
|
const cookieStore = cookies()
|
||||||
const supabase = createServerClient<Database>(
|
const supabase = createServerClient<Database>(
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
|
|
@ -75,7 +78,7 @@ export default async function Login({
|
||||||
|
|
||||||
if (!homeWorkspace) {
|
if (!homeWorkspace) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
homeWorkspaceError?.message || "An unexpected error occurred"
|
homeWorkspaceError?.message || t('login.errorUnexpected')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,7 +119,7 @@ export default async function Login({
|
||||||
const emailMatch = emailWhitelist?.includes(email)
|
const emailMatch = emailWhitelist?.includes(email)
|
||||||
if (!domainMatch && !emailMatch) {
|
if (!domainMatch && !emailMatch) {
|
||||||
return redirect(
|
return redirect(
|
||||||
`/login?message=Email ${email} is not allowed to sign up.`
|
`/login?message=${t('login.emailNotAllowed', { email })}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -138,10 +141,10 @@ export default async function Login({
|
||||||
return redirect(`/login?message=${error.message}`)
|
return redirect(`/login?message=${error.message}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect("/setup")
|
|
||||||
|
|
||||||
// USE IF YOU WANT TO SEND EMAIL VERIFICATION, ALSO CHANGE TOML FILE
|
// USE IF YOU WANT TO SEND EMAIL VERIFICATION, ALSO CHANGE TOML FILE
|
||||||
// return redirect("/login?message=Check email to continue sign in process")
|
// return redirect("/login?message=Check email to continue sign in process")
|
||||||
|
|
||||||
|
return redirect("/setup")
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleResetPassword = async (formData: FormData) => {
|
const handleResetPassword = async (formData: FormData) => {
|
||||||
|
|
@ -160,7 +163,7 @@ export default async function Login({
|
||||||
return redirect(`/login?message=${error.message}`)
|
return redirect(`/login?message=${error.message}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect("/login?message=Check email to reset password")
|
return redirect("/login?message=" + t('login.passwordResetMessage'))
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -172,43 +175,43 @@ export default async function Login({
|
||||||
<Brand />
|
<Brand />
|
||||||
|
|
||||||
<Label className="text-md mt-4" htmlFor="email">
|
<Label className="text-md mt-4" htmlFor="email">
|
||||||
Email
|
{t('login.email')}
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
className="mb-3 rounded-md border bg-inherit px-4 py-2"
|
className="mb-3 rounded-md border bg-inherit px-4 py-2"
|
||||||
name="email"
|
name="email"
|
||||||
placeholder="you@example.com"
|
placeholder={t('login.emailPlaceholder')}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Label className="text-md" htmlFor="password">
|
<Label className="text-md" htmlFor="password">
|
||||||
Password
|
{t('login.password')}
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
className="mb-6 rounded-md border bg-inherit px-4 py-2"
|
className="mb-6 rounded-md border bg-inherit px-4 py-2"
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
placeholder="••••••••"
|
placeholder={t('login.passwordPlaceholder')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SubmitButton className="mb-2 rounded-md bg-blue-700 px-4 py-2 text-white">
|
<SubmitButton className="mb-2 rounded-md bg-blue-700 px-4 py-2 text-white">
|
||||||
Login
|
{t('login.loginButton')}
|
||||||
</SubmitButton>
|
</SubmitButton>
|
||||||
|
|
||||||
<SubmitButton
|
<SubmitButton
|
||||||
formAction={signUp}
|
formAction={signUp}
|
||||||
className="border-foreground/20 mb-2 rounded-md border px-4 py-2"
|
className="border-foreground/20 mb-2 rounded-md border px-4 py-2"
|
||||||
>
|
>
|
||||||
Sign Up
|
{t('login.signUpButton')}
|
||||||
</SubmitButton>
|
</SubmitButton>
|
||||||
|
|
||||||
<div className="text-muted-foreground mt-1 flex justify-center text-sm">
|
<div className="text-muted-foreground mt-1 flex justify-center text-sm">
|
||||||
<span className="mr-1">Forgot your password?</span>
|
<span className="mr-1">{t('login.forgotPassword')}</span>
|
||||||
<button
|
<button
|
||||||
formAction={handleResetPassword}
|
formAction={handleResetPassword}
|
||||||
className="text-primary ml-1 underline hover:opacity-80"
|
className="text-primary ml-1 underline hover:opacity-80"
|
||||||
>
|
>
|
||||||
Reset
|
{t('login.reset')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,19 @@
|
||||||
"Enter API keys for each service you'd like to use.": "Enter API keys for each service you'd like to use.",
|
"Enter API keys for each service you'd like to use.": "Enter API keys for each service you'd like to use.",
|
||||||
"Set API Keys (optional)": "Set API Keys (optional)",
|
"Set API Keys (optional)": "Set API Keys (optional)",
|
||||||
"You are all set up!": "You are all set up!",
|
"You are all set up!": "You are all set up!",
|
||||||
"Setup Complete": "Setup Complete"
|
"Setup Complete": "Setup Complete",
|
||||||
|
|
||||||
|
"login": {
|
||||||
|
"email": "Email",
|
||||||
|
"emailPlaceholder": "you@example.com",
|
||||||
|
"password": "Password",
|
||||||
|
"passwordPlaceholder": "••••••••",
|
||||||
|
"loginButton": "Login",
|
||||||
|
"signUpButton": "Sign Up",
|
||||||
|
"forgotPassword": "Forgot your password?",
|
||||||
|
"reset": "Reset",
|
||||||
|
"emailNotAllowed": "Email {{email}} is not allowed to sign up.",
|
||||||
|
"passwordResetMessage": "Check email to reset password",
|
||||||
|
"errorUnexpected": "An unexpected error occurred"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,19 @@
|
||||||
"Enter API keys for each service you'd like to use.": "输入您希望使用的每个服务的 API 密钥。",
|
"Enter API keys for each service you'd like to use.": "输入您希望使用的每个服务的 API 密钥。",
|
||||||
"Set API Keys (optional)": "设置 API 密钥(可选)",
|
"Set API Keys (optional)": "设置 API 密钥(可选)",
|
||||||
"You are all set up!": "设置完成!",
|
"You are all set up!": "设置完成!",
|
||||||
"Setup Complete": "设置完成"
|
"Setup Complete": "设置完成",
|
||||||
|
|
||||||
|
"login": {
|
||||||
|
"email": "电子邮件",
|
||||||
|
"emailPlaceholder": "you@example.com",
|
||||||
|
"password": "密码",
|
||||||
|
"passwordPlaceholder": "••••••••",
|
||||||
|
"loginButton": "登录",
|
||||||
|
"signUpButton": "注册",
|
||||||
|
"forgotPassword": "忘记密码?",
|
||||||
|
"reset": "重置",
|
||||||
|
"emailNotAllowed": "邮箱 {{email}} 不允许注册。",
|
||||||
|
"passwordResetMessage": "请检查邮箱以重置密码",
|
||||||
|
"errorUnexpected": "发生了意外错误"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue