summaryrefslogtreecommitdiff
path: root/lib/users/session
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-10-15 21:38:21 +0900
committerjoonhoekim <26rote@gmail.com>2025-10-15 21:38:21 +0900
commita070f833d132e6370311c0bbdad03beb51d595df (patch)
tree9184292e4c2631ee0c7a7247f9728fc26de790f1 /lib/users/session
parent280a2628df810dc157357e0e4d2ed8076d020a2c (diff)
(김준회) 이메일 화이트리스트 (SMS 우회) 기능 추가 및 기존 로그인 과정 통합
Diffstat (limited to 'lib/users/session')
-rw-r--r--lib/users/session/helper.ts16
1 files changed, 15 insertions, 1 deletions
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)