Files
co-lite/solvway-admin-portal/app/api/auth/forgot-password/route.ts
T

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 });
}