fix(auth): 카카오 로그인 시 UUID 형식 검증 오류 수정 - #59
Conversation
카카오 OAuth 최초 로그인 시 PrismaAdapter가 User를 생성하기 전에 signIn 콜백이 실행되면서 카카오 숫자 ID(길이 10)로 UUID 컬럼을 조회하여 Prisma 에러가 발생하던 문제 수정. - signIn 콜백에 UUID 형식 검증 추가하여 비-UUID ID는 스킵 - events.createUser에서 신규 사용자 커스텀 필드 설정 처리 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesKakao 인증 및 최초 로그인 필드 설정 강화
로그인 페이지 UI 개선
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/auth/index.ts (1)
75-87: ⚡ Quick win오류 발생 시 디버깅을 위한 로깅 추가를 고려해 주세요.
createUser이벤트 핸들러 내saveFirstLoginFields호출 시 예기치 않은 오류가 발생하면, NextAuth 이벤트 특성상 오류가 조용히 무시될 수 있습니다. 이 경우 사용자는 생성되지만 커스텀 필드(kakaoId, nickname, termsAgreedAt)가 설정되지 않은 상태로 남을 수 있습니다.프로덕션 환경에서 문제 추적을 위해 try-catch와 로깅을 추가하는 것이 좋습니다.
💡 오류 로깅 추가 제안
events: { async createUser({ user }) { // PrismaAdapter가 User를 생성한 직후 호출됨 — 신규 사용자 커스텀 필드 설정 const account = await prisma.account.findFirst({ where: { userId: user.id, provider: 'kakao' }, select: { providerAccountId: true }, }) if (account) { - await saveFirstLoginFields(user.id, account.providerAccountId) + try { + await saveFirstLoginFields(user.id, account.providerAccountId) + } catch (error) { + console.error('[createUser] Failed to save first login fields:', { + userId: user.id, + error, + }) + } } }, },🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/auth/index.ts` around lines 75 - 87, The createUser event handler in the events object lacks error handling, which means if the account lookup or saveFirstLoginFields call fails, the error will be silently ignored and custom fields may not be set for the user. Wrap the entire logic inside the createUser async function (the prisma.account.findFirst call and the saveFirstLoginFields invocation) in a try-catch block, and add error logging in the catch block that includes the actual error details so failures can be tracked and debugged in production environments.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/lib/auth/index.ts`:
- Around line 75-87: The createUser event handler in the events object lacks
error handling, which means if the account lookup or saveFirstLoginFields call
fails, the error will be silently ignored and custom fields may not be set for
the user. Wrap the entire logic inside the createUser async function (the
prisma.account.findFirst call and the saveFirstLoginFields invocation) in a
try-catch block, and add error logging in the catch block that includes the
actual error details so failures can be tracked and debugged in production
environments.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 0af40e5f-02c6-4293-9de2-dd19bd0646e6
📒 Files selected for processing (1)
src/lib/auth/index.ts
카카오 OAuth 토큰 응답에 포함된 refresh_token_expires_in 필드가 Account 스키마에 없어서 linkAccount 단계에서 Prisma 에러 발생. PrismaAdapter를 래핑하여 Account 스키마에 정의된 필드만 저장하도록 필터링. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/auth/index.ts (1)
10-14: 💤 Low value
ACCOUNT_FIELDS화이트리스트 유지보수 관련 참고 사항이 접근 방식은 Kakao의
refresh_token_expires_in문제를 해결하지만, 향후 NextAuth 버전에서 새로운 Account 필드가 추가되면 자동으로 필터링되어 누락될 수 있습니다. 화이트리스트 방식의 의도된 동작이므로, 향후 NextAuth 업그레이드 시 이 목록도 함께 검토해야 합니다.또한
'id'필드는 일반적으로 어댑터에서 자동 생성되므로 OAuth 응답에 포함되지 않습니다. 제거해도 무방합니다.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/auth/index.ts` around lines 10 - 14, The ACCOUNT_FIELDS Set in the authentication configuration includes the 'id' field which is typically auto-generated by the adapter and will not be present in OAuth responses, making it unnecessary to include in the whitelist. Remove the 'id' field from the ACCOUNT_FIELDS Set. Additionally, add a comment above the ACCOUNT_FIELDS constant explaining that this whitelist is intentionally filtered to handle provider-specific fields like Kakao's refresh_token_expires_in, and that it should be reviewed during NextAuth version upgrades to ensure new Account fields are not inadvertently filtered out.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/lib/auth/index.ts`:
- Around line 10-14: The ACCOUNT_FIELDS Set in the authentication configuration
includes the 'id' field which is typically auto-generated by the adapter and
will not be present in OAuth responses, making it unnecessary to include in the
whitelist. Remove the 'id' field from the ACCOUNT_FIELDS Set. Additionally, add
a comment above the ACCOUNT_FIELDS constant explaining that this whitelist is
intentionally filtered to handle provider-specific fields like Kakao's
refresh_token_expires_in, and that it should be reviewed during NextAuth version
upgrades to ensure new Account fields are not inadvertently filtered out.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 7acd3e93-9631-4cc9-88c3-9421098461a1
📒 Files selected for processing (1)
src/lib/auth/index.ts
- 카카오 버튼 아이콘을 말풍선에서 TALK 아이콘으로 변경 - 버튼 배경색 #FFE812로 수정 - 약관 동의 문구를 서비스 가이드에 맞게 수정 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
signIn콜백에서 카카오 숫자 ID를 UUID 컬럼으로 조회하여 Prisma 에러 발생하던 문제 수정signIn콜백에 UUID 형식 검증을 추가하여 PrismaAdapter가 User를 생성하기 전 단계에서는 DB 조회를 스킵events.createUser핸들러를 추가하여 신규 사용자의 커스텀 필드(kakaoId, nickname, termsAgreedAt)를 안전하게 설정Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
릴리스 노트
버그 수정
새로운 기능
UI/스타일