Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
25 lines
981 B
TypeScript
25 lines
981 B
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";
|
|
|
|
type Ctx = { params: Promise<{ id: string }> };
|
|
|
|
/** Admin-typed temporary password; only the password pair is forwarded, and nothing is logged. */
|
|
export async function POST(req: NextRequest, { params }: Ctx) {
|
|
const token = await getToken();
|
|
if (!token) return unauthorized();
|
|
const { id } = await params;
|
|
const { password, confirmPassword } = (await req.json().catch(() => ({}))) as {
|
|
password?: string;
|
|
confirmPassword?: string;
|
|
};
|
|
const result = await callMobileApi<null>(`/api/admin/users/${encodeURIComponent(id)}/password`, {
|
|
method: "POST",
|
|
body: { password, confirmPassword },
|
|
token,
|
|
});
|
|
if (!result.ok) return errorResponse(result);
|
|
return new NextResponse(null, { status: 204 });
|
|
}
|