Skip to content

fix(auth): 카카오 로그인 시 kakao_id 중복 유니크 제약 위반 해결 - #82

Merged
evenif99 merged 10 commits into
devfrom
jw
Jun 19, 2026
Merged

evenif99 merged 10 commits into
devfrom
jw

Conversation

@evenif99

@evenif99 evenif99 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • 동일 카카오 계정으로 user 레코드가 중복 생성된 경우 kakao_id Unique constraint 위반으로 로그인 실패하는 버그 수정
  • saveFirstLoginFields 실행 전 기존 유저의 중복 kakao_idnull로 정리 후 현재 유저에 저장하도록 방어 로직 추가

원인

  • accounts 테이블 정리/DB 변경 등으로 동일 카카오 계정에 user 레코드가 2개 생성됨
  • 이전 user에 kakao_id가 남아있어 새 user에 저장 시 Unique constraint 실패

Test plan

  • 기존에 로그인 실패하던 팀원 계정으로 카카오 로그인 정상 동작 확인
  • 신규 카카오 계정 로그인 정상 동작 확인
  • 기존 정상 계정 로그인에 영향 없음 확인

🤖 Generated with Claude Code

Summary by CodeRabbit

릴리스 노트

  • New Features

    • 프로필 이미지 업로드 기능이 추가되었습니다. 인증된 사용자는 JPEG, PNG, WebP 형식의 5MB 이하 이미지를 업로드할 수 있습니다.
  • Bug Fixes

    • 첫 로그인 시 중복된 카카오 ID를 자동으로 정리하는 로직이 추가되어 계정 통합이 개선되었습니다.

evenif99 and others added 10 commits June 19, 2026 10:09
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat(user): 마이페이지 프로필 편집 및 이미지 업로드 구현

- 마이페이지 편집 페이지 UI 및 프로필 수정 로직 구현
- 프로필 이미지 업로드 API (Supabase Storage 연동)
- user/me API에 PATCH 메서드 추가 (닉네임, MBTI 수정)
- user 도메인 API client, hooks, constants 구성
- auth constants 및 lib/storage 유틸 추가
- API 명세서 업데이트
- dev 최신 반영 (사건기록, 홈 화면 개선)

Co-Authored-By: Claude <noreply@anthropic.com>
@
# Conflicts:
#	src/app/(page)/mypage/edit/page.module.scss
#	src/app/(page)/mypage/edit/page.tsx
#	src/app/api/user/me/route.ts
#	src/domains/user/api.ts
#	src/domains/user/hooks.ts
#	src/lib/auth/index.ts
동일 카카오 계정으로 user 레코드가 중복 생성된 경우,
기존 유저의 kakao_id를 null로 정리 후 현재 유저에 저장하도록 수정

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
talky-owl Ignored Ignored Jun 19, 2026 8:43am

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 75211eaf-c6f3-4cdd-a180-76cc656146e5

📥 Commits

Reviewing files that changed from the base of the PR and between f644ee5 and 88a0583.

📒 Files selected for processing (3)
  • .claude/settings.json
  • src/app/api/user/me/profile-image/route.ts
  • src/lib/auth/index.ts

📝 Walkthrough

Walkthrough

프로필 이미지를 Supabase Storage에 업로드하고 DB의 profileImageUrl을 갱신하는 POST API 엔드포인트를 신규 추가한다. 또한 첫 로그인 시 중복된 kakaoId를 null로 정리하는 헬퍼를 auth 모듈에 삽입하며, Claude 허용 커맨드 목록도 확장한다.

Changes

프로필 이미지 업로드 및 인증 정리

Layer / File(s) Summary
첫 로그인 중복 kakaoId 정리 헬퍼
src/lib/auth/index.ts
clearDuplicateKakaoId(kakaoId, currentUserId) 헬퍼가 추가되어, 동일한 kakaoId를 보유한 다른 사용자의 kakaoIdnull로 업데이트하며, saveFirstLoginFields 진입 직후 호출된다.
프로필 이미지 업로드 POST API
src/app/api/user/me/profile-image/route.ts
인증 확인(401), MIME 타입·5MB 크기 검증(400), Supabase Storage upsert 업로드(500), 타임스탬프 캐시 버스팅 URL 생성, Prisma profileImageUrl 갱신 후 성공 응답(200)까지의 전체 흐름을 구현한다.
Claude 허용 커맨드 목록 확장
.claude/settings.json
permissions.allow에 lint, DB URL 추출, Prisma 마이그레이션/push, 테이블 존재 여부 조회, 업로드 디렉터리 생성 등 14개 커맨드가 추가된다.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ProfileImageRoute as POST /profile-image
  participant SupabaseStorage
  participant PrismaDB

  Client->>ProfileImageRoute: multipart/form-data (file)
  ProfileImageRoute->>ProfileImageRoute: 세션 확인 → userId 추출
  ProfileImageRoute-->>Client: 401 (미인증)
  ProfileImageRoute->>ProfileImageRoute: MIME 타입 / 파일 크기 검증
  ProfileImageRoute-->>Client: 400 (검증 실패)
  ProfileImageRoute->>SupabaseStorage: upload {userId}/profile.{ext} (upsert:true)
  SupabaseStorage-->>ProfileImageRoute: 공개 URL
  ProfileImageRoute->>PrismaDB: user.update({ profileImageUrl: url?t=ts })
  PrismaDB-->>ProfileImageRoute: 업데이트 완료
  ProfileImageRoute-->>Client: 200 { profileImageUrl }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • I5-Project/TALKY-OWL#50: src/lib/auth/index.ts의 Kakao callbacks.signIn 및 첫 로그인 필드 저장 로직(saveFirstLoginFields)을 직접 수정하는 PR로, 이번 clearDuplicateKakaoId 추가와 동일 함수 흐름에 연결된다.
  • I5-Project/TALKY-OWL#59: saveFirstLoginFields에 UUID 검증 변경 및 events.createUser 연결을 추가한 PR로, 이번 PR의 중복 kakaoId 정리 삽입 지점과 동일한 함수 레벨에서 충돌 가능성이 있다.
  • I5-Project/TALKY-OWL#71: /api/user/me/profile-image 경로에 프로필 이미지 업로드·갱신 기능을 구현하려는 PR로, 이번 PR이 추가하는 동일 엔드포인트와 코드 레벨에서 직접 겹친다.

Poem

🐰 토끼가 이미지를 들고 서버로 뛰어가네,
MIME 타입 검사, 5MB 벽도 넘어서,
Supabase 창고에 upsert로 쏙 넣고,
?t=timestamp 붙여 캐시를 무찌르고,
Prisma DB에 새 URL 새겨 넣었다네 🌟
kakaoId 중복도 null로 싹 정리했지,
오늘도 깔끔한 토끼의 하루! 🐾

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jw

Comment @coderabbitai help to get the list of available commands and usage tips.

@evenif99
evenif99 merged commit c6221fc into dev Jun 19, 2026
1 of 3 checks passed
@evenif99
evenif99 deleted the jw branch June 19, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant