diff options
| author | joonhoekim <26rote@gmail.com> | 2025-03-25 15:55:45 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-03-25 15:55:45 +0900 |
| commit | 1a2241c40e10193c5ff7008a7b7b36cc1d855d96 (patch) | |
| tree | 8a5587f10ca55b162d7e3254cb088b323a34c41b /lib/users/verifyOtp.ts | |
initial commit
Diffstat (limited to 'lib/users/verifyOtp.ts')
| -rw-r--r-- | lib/users/verifyOtp.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/users/verifyOtp.ts b/lib/users/verifyOtp.ts new file mode 100644 index 00000000..5de76f90 --- /dev/null +++ b/lib/users/verifyOtp.ts @@ -0,0 +1,28 @@ +// lib/users/verifyOtp.ts +import { findEmailandOtp } from '@/lib/users/service' + +// "email과 code가 맞으면 유저 정보, 아니면 null" 형태로 작성 +export async function verifyOtp(email: string, code: string) { + // DB에서 email과 code가 맞는지, 만료 안됐는지 검증 + const otpRecord = await findEmailandOtp(email, code) + if (!otpRecord) { + return null + } + + // 만료 체크 + if (otpRecord.otpExpires && otpRecord.otpExpires < new Date()) { + return null + } + + // 여기서 otpRecord에 유저 정보가 있다고 가정 + // 예: otpRecord.userId, otpRecord.userName, otpRecord.email 등 + // 실제 DB 설계에 맞춰 필드명을 조정하세요. + return { + email: otpRecord.email, + name: otpRecord.name, + id: otpRecord.id, + imageUrl: otpRecord.imageUrl, + companyId: otpRecord.companyId, + domain: otpRecord.domain, + } +}
\ No newline at end of file |
