마에스트로 상세화면에 암호 초기화 버튼 추가 (암호 초기화: 123456)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { resetMaestroPassword } from "@/lib/maestros";
|
||||
import { ApiError } from "@/lib/errors";
|
||||
import { withApiHandler } from "@/lib/api-handler";
|
||||
import { logger } from "@/lib/logger";
|
||||
|
||||
const CTX = "maestros/[id]/reset-password";
|
||||
|
||||
export const POST = withApiHandler<{ id: string }>(
|
||||
CTX,
|
||||
async (_request, { params, t0 }) => {
|
||||
const { id } = await params;
|
||||
const maestroID = Number(id);
|
||||
|
||||
if (!Number.isInteger(maestroID) || maestroID <= 0) {
|
||||
throw new ApiError("Invalid maestro id", 400);
|
||||
}
|
||||
|
||||
const found = await resetMaestroPassword(maestroID);
|
||||
|
||||
if (!found) {
|
||||
throw new ApiError("Not found", 404);
|
||||
}
|
||||
|
||||
logger.info(CTX, "password reset", {
|
||||
id: maestroID,
|
||||
duration: Date.now() - t0,
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user