diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-05 16:46:43 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-05 16:46:43 +0900 |
| commit | a2c78d3a00c569a37ab93f65b58a11ba3519b596 (patch) | |
| tree | 1909ff3d52bb6f17a5b376d332255291cc71ecf5 /lib/pq | |
| parent | 208ed7ff11d0f822d3d243c5833d31973904349e (diff) | |
(김준회) 실사의뢰/실사재의뢰 누락된 userId 추가해서 pendingActions에 추가하도록 변경
Diffstat (limited to 'lib/pq')
| -rw-r--r-- | lib/pq/service.ts | 22 |
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: "인증된 사용자만 실사를 재의뢰할 수 있습니다." }
|
