From a6ad5fcfb65772b9ae240d9fa02bf9ed1a9160c9 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Wed, 5 Nov 2025 10:43:11 +0900 Subject: (김준회) 세션에 epId 추가 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/auth/[...nextauth]/route.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index be50c022..75ddfe85 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -37,6 +37,7 @@ declare module "next-auth" { sessionExpiredAt?: number | null dbSessionId?: string | null roles?: string[] // ✅ roles 배열 추가 + epId?: string | null // ✅ epId 추가 (users 테이블에서) } } @@ -51,6 +52,7 @@ declare module "next-auth" { authMethod?: AuthMethod dbSessionId?: string | null roles?: string[] // ✅ roles 배열 추가 + epId?: string | null // ✅ epId 추가 (users 테이블에서) } } @@ -67,6 +69,7 @@ declare module "next-auth/jwt" { sessionExpiredAt?: number | null dbSessionId?: string | null roles?: string[] // ✅ roles 배열 추가 + epId?: string | null // ✅ epId 추가 (users 테이블에서) } } @@ -161,6 +164,7 @@ export const authOptions: NextAuthOptions = { reAuthTime, authMethod: 'otp' as AuthMethod, roles: userRoles, // ✅ roles 배열 추가 + epId: user.epId, // ✅ epId 추가 (users 테이블에서) } }, }), @@ -320,6 +324,7 @@ export const authOptions: NextAuthOptions = { token.dbSessionId = user.dbSessionId token.roles = user.roles token.ownerCompanyId = user.ownerCompanyId + token.epId = user.epId // ✅ epId 추가 } // ✅ 기존 토큰이 있고 로그인이 아닌 경우, DB에서 최신 사용자 정보 조회 @@ -339,6 +344,7 @@ export const authOptions: NextAuthOptions = { token.companyId = latestUser.companyId token.techCompanyId = latestUser.techCompanyId token.ownerCompanyId = latestUser.ownerCompanyId + token.epId = latestUser.epId // ✅ epId 최신 정보로 업데이트 // roles 정보도 최신으로 업데이트 const userRoles = await getUserRoles(parseInt(token.id)) @@ -365,6 +371,7 @@ export const authOptions: NextAuthOptions = { token.companyId = latestUser.companyId token.techCompanyId = latestUser.techCompanyId token.ownerCompanyId = latestUser.ownerCompanyId + token.epId = latestUser.epId // ✅ SAML 시 epId 설정 token.roles = await getUserRoles(numericUserId) } @@ -444,6 +451,7 @@ export const authOptions: NextAuthOptions = { sessionExpiredAt: token.sessionExpiredAt as number | null, dbSessionId: token.dbSessionId as string | null, roles: token.roles as string[] || [], // ✅ roles 정보 추가 + epId: token.epId as string | null, // ✅ epId 추가 } } return session -- cgit v1.2.3