Files
co-lite/solvway-admin-portal/app/api/auth/change-password/route.ts
T
ngqileandClaude Opus 5.5 dd9bbbe036 fix: browser context on password-change history, plain settings errors, New password label
Found in the browser check: change-password history rows had no browser
or IP, settings errors named internal fields, and the dialog's new
password field read just "Password".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-30 14:52:15 +08:00

26 lines
1.1 KiB
TypeScript

import { NextResponse, type NextRequest } from "next/server";
import { callMobileApi } from "@/app/lib/server/mobileApi";
import { getToken } from "@/app/lib/server/session";
import { errorResponse, unauthorized } from "@/app/lib/server/apiRoute";
import { clientContextHeaders } from "@/app/lib/server/clientContext";
/** The signed-in admin changes their own password; only the three fields are forwarded, and nothing is logged. */
export async function POST(req: NextRequest) {
const token = await getToken();
if (!token) return unauthorized();
const { currentPassword, newPassword, confirmPassword } = (await req.json().catch(() => ({}))) as {
currentPassword?: string;
newPassword?: string;
confirmPassword?: string;
};
const result = await callMobileApi<null>("/api/admin/auth/change-password", {
method: "POST",
body: { currentPassword, newPassword, confirmPassword },
token,
// The browser IP and user agent go into the login history rows this call writes.
headers: clientContextHeaders(req),
});
if (!result.ok) return errorResponse(result);
return new NextResponse(null, { status: 204 });
}