// components/account/ConfirmIdentity.tsx "use client"; import { useState } from "react"; export default function ConfirmIdentity({ defaultIdentifier, onSuccess, }: { defaultIdentifier: string; // prefill with username or email you show on the page onSuccess: () => void; // called after re-auth succeeds }) { const [open, setOpen] = useState(false); const [identifier, setIdentifier] = useState(defaultIdentifier); const [password, setPassword] = useState(""); const [busy, setBusy] = useState(false); const [err, setErr] = useState(null); async function submit() { setBusy(true); setErr(null); try { const res = await fetch("/api/auth/reconfirm", { method: "POST", headers: { "Content-Type": "application/json" }, credentials: "include", body: JSON.stringify({ identifier, password }), }); const j = await res.json().catch(() => ({})); if (!res.ok) throw new Error(j?.error || "Failed"); setOpen(false); setPassword(""); onSuccess(); // now do the sensitive call } catch (e: any) { setErr(e?.message || "Re-auth failed"); } finally { setBusy(false); } } return ( <> {/* wherever you need the step-up, render a button that opens this */} {open && (

Confirm it’s you

setIdentifier(e.target.value)} /> setPassword(e.target.value)} /> {err &&
{err}
}
)} ); }