Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
20 lines
1.0 KiB
TypeScript
20 lines
1.0 KiB
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
import { callMobileApi } from "@/app/lib/server/mobileApi";
|
|
|
|
// POST → /api/admin/auth/forgot-password (public, no token). The browser always gets 200 {ok:true}:
|
|
// the answer must not reveal whether the account exists, so upstream errors are never forwarded.
|
|
// Same-origin and body-size checks are enforced for every /api write by middleware.
|
|
export async function POST(req: NextRequest) {
|
|
const body = (await req.json().catch(() => ({}))) as { company?: unknown; username?: unknown; email?: unknown };
|
|
const username = typeof body.username === "string" ? body.username.trim() : "";
|
|
const email = typeof body.email === "string" ? body.email.trim() : "";
|
|
const company = typeof body.company === "string" ? body.company.trim() : "";
|
|
if (username && email) {
|
|
await callMobileApi("/api/admin/auth/forgot-password", {
|
|
method: "POST",
|
|
body: { ...(company && { company }), username, email },
|
|
});
|
|
}
|
|
return NextResponse.json({ ok: true });
|
|
}
|