fix(guard): plm_admin(FITO isAdmin)도 모모 ADMIN으로 인정 — 403 해소
Deploy momo-erp / deploy (push) Successful in 49s

This commit is contained in:
chpark
2026-04-26 00:26:57 +09:00
parent 9d042862f8
commit 3f97e4eac6
+4 -4
View File
@@ -6,16 +6,16 @@ import type { User } from "@/types";
export async function requireMomoUser(): Promise<{ user: User } | NextResponse> {
const user = await getSession();
if (!user) return NextResponse.json({ success: false, message: "로그인이 필요합니다." }, { status: 401 });
if (user.role !== "USER" && user.role !== "ADMIN") {
return NextResponse.json({ success: false, message: "MOMO 사용자만 접근 가능합니다." }, { status: 403 });
}
// MOMO 가입자(role) + FITO 사용자 모두 통과
return { user };
}
export async function requireMomoAdmin(): Promise<{ user: User } | NextResponse> {
const r = await requireMomoUser();
if (r instanceof NextResponse) return r;
if (r.user.role !== "ADMIN") {
// ADMIN 판정: MOMO role==='ADMIN' OR FITO isAdmin===true (plm_admin 등)
const isAdmin = r.user.role === "ADMIN" || r.user.isAdmin === true;
if (!isAdmin) {
return NextResponse.json({ success: false, message: "관리자 권한이 필요합니다." }, { status: 403 });
}
return r;