From a070f833d132e6370311c0bbdad03beb51d595df Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Wed, 15 Oct 2025 21:38:21 +0900 Subject: (김준회) 이메일 화이트리스트 (SMS 우회) 기능 추가 및 기존 로그인 과정 통합 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/users/session/helper.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/users/session/helper.ts') diff --git a/lib/users/session/helper.ts b/lib/users/session/helper.ts index 03bfd7bc..4c511340 100644 --- a/lib/users/session/helper.ts +++ b/lib/users/session/helper.ts @@ -1,5 +1,6 @@ import { authenticateWithSGips, verifyExternalCredentials } from "../auth/verifyCredentails"; import { SessionRepository } from "./repository"; +import { isEmailWhitelisted } from "@/lib/email-whitelist/service"; // lib/session/helpers.ts - NextAuth 헬퍼 함수들 개선 export const authHelpers = { @@ -35,6 +36,16 @@ export const authHelpers = { return { success: false, error: 'INVALID_CREDENTIALS' } } + // 화이트리스트 체크하여 MFA 타입 결정 + const isWhitelisted = await isEmailWhitelisted(authResult.user.email); + const mfaType = isWhitelisted ? 'email' : 'sms'; + + console.log('Whitelist check:', { + email: authResult.user.email, + isWhitelisted, + mfaType + }); + // DB에 임시 인증 세션 생성 const expiresAt = new Date(Date.now() + (10 * 60 * 1000)) // 10분 후 만료 const tempAuthKey = await SessionRepository.createTempAuthSession({ @@ -49,6 +60,7 @@ export const authHelpers = { userId: authResult.user.id, email: authResult.user.email, authMethod: provider, + mfaType, expiresAt }) @@ -56,7 +68,9 @@ export const authHelpers = { success: true, tempAuthKey, userId: authResult.user.id, - email: authResult.user.email + email: authResult.user.email, + mfaType, // 'email' 또는 'sms' + userName: authResult.user.name, // Email OTP 전송 시 필요 } } catch (error) { console.error('First auth error:', error) -- cgit v1.2.3