"use client"; import { useRouter } from "next/navigation"; import { type FormEvent, useState } from "react"; import { type ApiError, api, setCsrf } from "@/lib/client/api"; export default function ChangePasswordPage() { const router = useRouter(); const [err, setErr] = useState(null); const [busy, setBusy] = useState(false); async function submit(e: FormEvent) { e.preventDefault(); setBusy(true); setErr(null); const fd = new FormData(e.currentTarget); try { const r = await api<{ csrfToken: string }>("/api/admin/auth/change-password", { json: { currentPassword: fd.get("currentPassword"), newPassword: fd.get("newPassword"), confirm: fd.get("confirm"), }, }); setCsrf(r.csrfToken); router.replace("/admin"); router.refresh(); } catch (e2) { const ae = e2 as ApiError; setErr( Array.isArray(ae.details) && typeof ae.details[0] === "string" ? `${ae.message}` : (ae.message ?? "Failed"), ); } finally { setBusy(false); } } return (

Security

Set a new password

The bootstrap password only works once. Choose at least 12 characters with three character classes; it must not be a well-known password or contain your username.

{err && (

{err}

)}
); }