import { useState, type FormEvent } from "react"; import { useAuth } from "../auth"; import { ApiError } from "../api"; export function Login() { const { login } = useAuth(); const [user, setUser] = useState(""); const [password, setPassword] = useState(""); const [totp, setTotp] = useState(""); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const submit = async (e: FormEvent): Promise => { e.preventDefault(); setBusy(true); setError(null); try { await login(user, password, totp); } catch (err) { setError(err instanceof ApiError && err.status === 429 ? "Trop de tentatives, patiente." : "Identifiants invalides."); } finally { setBusy(false); } }; const field = "w-full rounded-md bg-surface-2 border border-border px-3 py-2 text-fg placeholder:text-muted ring-accent"; return (

CHLOVA

Accès propriétaire — authentification forte.

setUser(e.target.value)} /> setPassword(e.target.value)} /> setTotp(e.target.value)} /> {error &&

{error}

}
); }