summaryrefslogtreecommitdiff
path: root/lib/pq/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pq/service.ts')
-rw-r--r--lib/pq/service.ts22
1 files changed, 19 insertions, 3 deletions
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: "인증된 사용자만 실사를 재의뢰할 수 있습니다." }