"use client"; import * as React from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { authClient } from "@/lib/auth-client"; import { AuthCard } from "@/components/auth/auth-card"; import { PasswordInput } from "@/components/auth/password-input"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Field, FieldError, Label } from "@/components/ui/label"; import { Alert } from "@/components/ui/alert"; export function LoginForm({ next, verified, reset }: { next?: string; verified?: boolean; reset?: boolean }) { const router = useRouter(); const [email, setEmail] = React.useState(""); const [password, setPassword] = React.useState(""); const [remember, setRemember] = React.useState(true); const [error, setError] = React.useState(null); const [loading, setLoading] = React.useState(false); async function onSubmit(e: React.FormEvent) { e.preventDefault(); setError(null); setLoading(true); const { error } = await authClient.signIn.email({ email: email.trim(), password, rememberMe: remember, callbackURL: next && next.startsWith("/") ? next : "/dashboard" }); setLoading(false); if (error) { setError(error.status === 429 ? "Too many attempts. Wait a minute and try again." : error.message ?? "Invalid email or password."); return; } router.push(next && next.startsWith("/") ? next : "/dashboard"); router.refresh(); } return ( Invitation only — ask your administrator.{" "} Invited? Create your account } >
{verified ? Your email is verified. Log in to continue. : null} {reset ? Your password was updated. Log in with the new one. : null} {error ? {error} : null} setEmail(e.target.value)} placeholder="you@company.com" autoFocus />
Forgot password?
setPassword(e.target.value)} />
); }