From a2c78d3a00c569a37ab93f65b58a11ba3519b596 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Wed, 5 Nov 2025 16:46:43 +0900 Subject: (김준회) 실사의뢰/실사재의뢰 누락된 userId 추가해서 pendingActions에 추가하도록 변경 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pq/service.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'lib/pq') diff --git a/lib/pq/service.ts b/lib/pq/service.ts index d3974964..b39bf7bd 100644 --- a/lib/pq/service.ts +++ b/lib/pq/service.ts @@ -2985,10 +2985,26 @@ export async function cancelInvestigationAction(investigationIds: number[]) { } // 실사 재의뢰 서버 액션 -export async function reRequestInvestigationAction(investigationIds: number[]) { +export async function reRequestInvestigationAction( + investigationIds: number[], + currentUser?: { id: number } // ✅ 핸들러에서 호출 시 사용자 정보 전달 +) { try { - const session = await getServerSession(authOptions) - const userId = session?.user?.id ? Number(session.user.id) : null + let userId: number | null = null; + + if (currentUser) { + // 핸들러에서 호출 시 (결재 승인 후) + userId = currentUser.id; + + // ✅ 핸들러에서 호출 시 userId 검증: 없으면 잘못된 상황 (예외 처리) + if (!userId || userId <= 0) { + throw new Error('핸들러에서 호출 시 currentUser.id가 필수입니다.'); + } + } else { + // 직접 호출 시 (세션에서 가져오기) + const session = await getServerSession(authOptions); + userId = session?.user?.id ? Number(session.user.id) : null; + } if (!userId) { return { success: false, error: "인증된 사용자만 실사를 재의뢰할 수 있습니다." } -- cgit v1.2.3