account auth cleanup

This commit is contained in:
makearmy 2025-09-30 17:04:37 -04:00
parent 6162722c87
commit 94de501a49
5 changed files with 41 additions and 22 deletions

View file

@ -11,10 +11,8 @@ async function handle(req: Request) {
const bearer = requireBearer(req);
const body = await req.json().catch(() => ({}));
const current =
String(body?.current ?? body?.current_password ?? "").trim();
const next =
String(body?.next ?? body?.new_password ?? "").trim();
const current = String(body?.current ?? body?.current_password ?? "").trim();
const next = String(body?.next ?? body?.new_password ?? "").trim();
if (!current || !next) return bad("Missing current and/or new password");
if (next.length < 8) return bad("Password must be at least 8 characters");
@ -22,7 +20,7 @@ async function handle(req: Request) {
const res = await fetch(`${API}/users/me`, {
method: "PATCH",
headers: {
Authorization: bearer,
Authorization: `Bearer ${bearer}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ password: next, old_password: current }),