Files
co-lite/solvway-admin-portal/app/api/auth/forgot-password/route.ts
T
ngqileandClaude Opus 5.5 da813874ec feat(admin-portal): forgot password page; own account cannot be deactivated
/forgot-password always shows the same message; the route never forwards upstream
errors or a token. /api/admin/me now returns id and username so the user form can
lock the Active switch on your own account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-26 21:38:42 +08:00

16 lines
889 B
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 { username?: unknown; email?: unknown };
const username = typeof body.username === "string" ? body.username.trim() : "";
const email = typeof body.email === "string" ? body.email.trim() : "";
if (username && email) {
await callMobileApi("/api/admin/auth/forgot-password", { method: "POST", body: { username, email } });
}
return NextResponse.json({ ok: true });
}