"use client"; import { useState, Suspense } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import { authClient } from "~/lib/auth-client"; import { Card, CardContent } from "~/components/ui/card"; import { Input } from "~/components/ui/input"; import { Button } from "~/components/ui/button"; import { Label } from "~/components/ui/label"; import { toast } from "sonner"; import { Logo } from "~/components/branding/logo"; import { LegalModal } from "~/components/ui/legal-modal"; import { env } from "~/env"; import { Mail, Lock, ArrowRight, Shield } from "lucide-react"; interface SignInFormProps { allowRegistration: boolean; } export function SignInForm({ allowRegistration }: SignInFormProps) { const authentikEnabled = env.NEXT_PUBLIC_AUTHENTIK_ENABLED === true; const router = useRouter(); const searchParams = useSearchParams(); const callbackUrl = searchParams.get("callbackUrl") ?? "/dashboard"; const signupDisabled = searchParams.get("signup") === "disabled"; const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); async function handleSignIn(e: React.FormEvent) { e.preventDefault(); setLoading(true); const { error } = await authClient.signIn.email({ email, password }); setLoading(false); if (error) { toast.error(error.message ?? "Invalid email or password"); } else { toast.success("Signed in successfully!"); router.push(callbackUrl); router.refresh(); } } async function handleSocialSignIn() { setLoading(true); try { await authClient.signIn.oauth2({ providerId: "authentik", callbackURL: callbackUrl, }); } catch (error) { console.error("[SSO Error]", error); setLoading(false); } } return (
Sign in to your account
Don't have an account?{" "} Sign up
)}
By signing in you agree to our{" "}