This commit is contained in:
parent
ff90692b63
commit
27d7709693
|
|
@ -1,4 +1,3 @@
|
||||||
import { useTranslation } from 'react-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"
|
||||||
|
|
@ -20,8 +19,6 @@ 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!,
|
||||||
|
|
@ -78,7 +75,7 @@ export default async function Login({
|
||||||
|
|
||||||
if (!homeWorkspace) {
|
if (!homeWorkspace) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
homeWorkspaceError?.message || t('login.errorUnexpected')
|
homeWorkspaceError?.message || "An unexpected error occurred"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +116,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=${t('login.emailNotAllowed', { email })}`
|
`/login?message=Email ${email} is not allowed to sign up.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -141,10 +138,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) => {
|
||||||
|
|
@ -163,7 +160,7 @@ export default async function Login({
|
||||||
return redirect(`/login?message=${error.message}`)
|
return redirect(`/login?message=${error.message}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect("/login?message=" + t('login.passwordResetMessage'))
|
return redirect("/login?message=Check email to reset password")
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -175,43 +172,43 @@ export default async function Login({
|
||||||
<Brand />
|
<Brand />
|
||||||
|
|
||||||
<Label className="text-md mt-4" htmlFor="email">
|
<Label className="text-md mt-4" htmlFor="email">
|
||||||
{t('login.email')}
|
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={t('login.emailPlaceholder')}
|
placeholder="you@example.com"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Label className="text-md" htmlFor="password">
|
<Label className="text-md" htmlFor="password">
|
||||||
{t('login.password')}
|
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={t('login.passwordPlaceholder')}
|
placeholder="••••••••"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<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">
|
||||||
{t('login.loginButton')}
|
Login
|
||||||
</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"
|
||||||
>
|
>
|
||||||
{t('login.signUpButton')}
|
Sign Up
|
||||||
</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">{t('login.forgotPassword')}</span>
|
<span className="mr-1">Forgot your password?</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"
|
||||||
>
|
>
|
||||||
{t('login.reset')}
|
Reset
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue