password change debug update

This commit is contained in:
makearmy 2025-09-30 20:49:37 -04:00
parent 16ae6d9c1c
commit 064385ce42
2 changed files with 49 additions and 18 deletions

View file

@ -27,17 +27,22 @@ export default function PasswordChange() {
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ current, next }),
});
if (r.status === 401) {
// Wrong current or expired token; the route returns a friendly message for wrong current.
const j = await r.json().catch(() => ({}));
setMsg(j?.error || "Re-authentication required.");
return;
}
const j = await r.json().catch(() => ({}));
// ⬇️ Parse JSON **then** use debug if present
const j = await r.json().catch(() => ({} as any));
if (!r.ok) {
setMsg(j?.error || "Password change failed");
// ⬇️ This is the "debug block" so you can see the upstream reason
setMsg(
j?.error
? j?.debug
? `${j.error} (${j.debug})`
: j.error
: "Password change failed"
);
return;
}
setMsg("Password updated.");
setCurrent("");
setNext("");