"use client"; import { Suspense, useEffect, useState } from "react"; import { useSearchParams } from "next/navigation"; import { Fingerprint } from "lucide-react"; import { biolock, enrolledHere, hasReader } from "@/lib/biolock/use-biolock"; const buttonClass = "flex h-11 w-full items-center justify-center gap-3 rounded-full font-mono text-[12.5px] font-semibold uppercase tracking-[0.07em] transition-colors disabled:pointer-events-none disabled:opacity-50"; const solid = `${buttonClass} bg-foreground text-background hover:bg-foreground/85`; const outline = `${buttonClass} border border-foreground/25 text-foreground hover:border-foreground/60`; function LoginForm() { const params = useSearchParams(); const next = params.get("next") || "/account"; const addToken = params.get("add"); const [reader, setReader] = useState(null); const [enrolled, setEnrolled] = useState(false); const [name, setName] = useState(""); const [pending, setPending] = useState(false); const [error, setError] = useState(null); useEffect(() => { void hasReader().then(setReader); setEnrolled(enrolledHere().length > 0); }, []); const run = async (mode: "signin" | "create" | "link") => { setPending(true); setError(null); try { await biolock(mode, mode === "create" ? { name } : mode === "link" ? { token: addToken ?? "" } : {}); window.location.assign(`/auth/callback?next=${encodeURIComponent(next)}`); } catch (failure) { setError(failure instanceof Error ? failure.message : "Sign-in failed. Try again."); setEnrolled(enrolledHere().length > 0); setPending(false); } }; return (

Free account

{addToken ? "Add this device" : "Sign in"}

{addToken ? "Set up this device so it signs in with its own fingerprint or face." : "Save lessons to come back to. Sign in with BioLock: just your fingerprint or face, on this device. No passwords."}

{error && (

{error}

)} {reader === false && (

This device has no fingerprint or face reader, so it can't sign in. Use a phone or a computer with Touch ID, Face ID or Windows Hello.

)}
{addToken ? ( ) : ( <> {enrolled && ( )}
{ event.preventDefault(); void run("create"); }} > {enrolled &&

New here? Make a free account.

} setName(event.target.value)} className="h-11 w-full rounded-full border border-foreground/25 bg-transparent px-5 text-[15px] outline-none focus:border-foreground/60" />
{!enrolled && (

Already have an account on another device? Open your account page there and choose “Add a device”.

)} )}

By signing in you agree to the account rules. Read the{" "} Privacy Policy.

); } export default function LoginPage() { return (
); }