fix(orders): '내 발주 이력' 은 admin 이라도 본인 발주만 (mine=true)
Deploy momo-erp / deploy (push) Successful in 2m6s

momo5315(배연진) 같은 admin 임직원이 사용자 측 '내 발주 이력' 페이지를
열면 모든 발주가 노출되던 문제. admin 판정만으로는 부족 — 메뉴 의도가
'본인 것' 이라 isAdmin 여부 무관 customer_objid 본인 매칭 필요.

- list API: body.mine === true 면 admin 이어도 본인 발주만
- /m/orders/page.tsx fetch 에 mine: true 추가
- admin 메뉴(/m/admin/*)는 mine 안 보냄 → 기존대로 전체 노출
This commit is contained in:
chpark
2026-05-14 01:31:07 +09:00
parent 13d02cac6a
commit 88686d0461
2 changed files with 6 additions and 4 deletions
+1
View File
@@ -69,6 +69,7 @@ export default function MyOrdersPage() {
const res = await fetch("/api/m/orders/list", {
method: "POST", headers: { "Content-Type": "application/json" },
body: JSON.stringify({
mine: true, // '내 발주 이력' — admin 이라도 본인 customer_objid 만
status: status || undefined,
dateFrom: dateFrom || undefined,
dateTo: dateTo || undefined,
+5 -4
View File
@@ -7,18 +7,19 @@ export async function POST(req: NextRequest) {
if (r instanceof NextResponse) return r;
const body = await req.json().catch(() => ({}));
const { dateFrom, dateTo, status, customerObjid, keyword } = body as {
const { dateFrom, dateTo, status, customerObjid, keyword, mine } = body as {
dateFrom?: string; dateTo?: string; status?: string; customerObjid?: string; keyword?: string;
mine?: boolean;
};
const conditions: string[] = ["COALESCE(O.is_del,'N') != 'Y'"];
const params: unknown[] = [];
let i = 1;
// admin 판정 — MOMO/FITO 세션 모두 호환 (FITO 세션은 role 필드 없음 → userType/isAdmin 으로 판정)
const isAdmin = r.user.isAdmin === true || r.user.role === "ADMIN" || r.user.userType === "A";
if (!isAdmin) {
// USER 권한 — 본인 발주만. user.objid 가 undefined 인 세션 있어 user_id 로 폴백.
// 사용자 측 '내 발주 이력' 페이지는 mine=true 로 호출 → admin 이라도 본인 발주만.
// admin 메뉴 (출고관리/입금관리/계산서 등) 는 mine 안 보냄 → 전체 또는 customerObjid 필터.
if (mine === true || !isAdmin) {
const own = r.user.objid ?? r.user.userId;
conditions.push(`O.customer_objid IN ($${i++}, $${i++})`);
params.push(own, r.user.userId);