Skip to content

Conversation

@earlgrey02
Copy link
Member

@earlgrey02 earlgrey02 commented Feb 9, 2026

작업 내용

  • 소셜 프로필 연동 기능 구현
  • 로그인 기능 리팩토링

참고

  • Elvis 연산자(?:)는 메서드 체이닝을 더 이어가기가 불편해서 유틸리티(orElse()) 하나 만들었습니다.
  • 도메인 엔티티의 변경 의도가 더 명확하게 보이도록, 로그인 기능 내의 프로퍼티를 변경하는 부분은 따로 엔티티 메서드로 빼냈습니다.

관련 이슈

@earlgrey02 earlgrey02 requested review from 1117mg and mjk25 February 9, 2026 09:56
@earlgrey02 earlgrey02 self-assigned this Feb 9, 2026
@earlgrey02 earlgrey02 added the feature 기능 구현 label Feb 9, 2026
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🤖 Gemini Code Review

✅ 변경 사항 요약

  • OAuth 인증 응답(Google)에 성, 이름, 프로필 이미지 URL 필드가 추가되었습니다.
  • 신규 사용자 로그인 시 OAuth 응답을 기반으로 Profile 엔티티를 생성하고 저장하는 로직이 추가되었습니다.
  • 기존 사용자 로그인 시 이메일만 업데이트됩니다.

🚨 치명적인 이슈 (Critical Issues)

  • 🛑 AuthService.kt
    • Problem: 기존 사용자가 로그인할 경우, OAuth 클라이언트로부터 받은 최신 프로필 정보(이름, 이미지 URL)를 Profile 엔티티에 반영하는 로직이 누락되었습니다. 신규 사용자에게만 프로필이 생성되고, 이미 존재하는 사용자의 프로필 데이터는 동기화되지 않아 데이터가 불일치할 수 있습니다.
    • Fix: 기존 사용자의 경우에도 ProfileRepository를 통해 해당 유저의 프로필을 조회하고, OAuth 응답으로 받은 최신 firstName, lastName, imageUrl로 업데이트해야 합니다.

✏️ 파일별 상세 리뷰

core/src/main/kotlin/com/retoday/core/domain/auth/client/GoogleClient.kt

  • 📍 Issue: 응답 본문을 Map<String, String>으로 명시하여 타입 안정성을 높였으나, 내부에서 getValue()를 사용하여 필드를 추출합니다. 구글 OpenID Connect 응답에서 해당 필드(given_name, family_name, picture)가 스코프 설정이나 사용자 데이터 누락 등의 이유로 없을 경우 NoSuchElementException이 발생합니다.
  • Improvement: 해당 필드가 선택적일 가능성이 있다면, get(FIELD)를 사용하여 null 체크를 수행하거나, 기본값을 제공하는 로직으로 변경하여 예외 발생 위험을 줄여야 합니다. 현재 DTO(GetOAuthUserResponse) 필드가 모두 Non-nullable이므로, 필수 데이터로 간주한다면 현재 방식은 유지될 수 있습니다.

core/src/main/kotlin/com/retoday/core/domain/auth/service/AuthService.kt

  • 📍 Issue: login 메서드 내에서 OAuth 응답을 받아 User 엔티티 저장 후, 신규 사용자 여부(isNew)를 판단하여 프로필을 저장합니다. 이 때 프로필 저장 로직이 apply 블록 내에 중첩되어 있어 가독성이 떨어지며, 사용자 저장 후 반드시 실행되어야 하는 로직임에도 불구하고 부수 효과로 처리되고 있습니다.
  • 📍 Issue: 사용자 저장 시 userRepository.save(it)을 호출하고 바로 .apply { ... }를 통해 프로필을 생성합니다. 사용자 저장 후 id가 채워진 객체가 반환되므로 id!! 사용은 안전하지만, 트랜잭션 경계 내에서 일관성 있는 로직 흐름을 유지하도록 분리하는 것이 좋습니다.

@earlgrey02 earlgrey02 marked this pull request as draft February 9, 2026 10:10
@earlgrey02 earlgrey02 force-pushed the feature/50-social-profile-sync branch from 9821311 to 1edd4c1 Compare February 9, 2026 11:51
@earlgrey02 earlgrey02 marked this pull request as ready for review February 9, 2026 11:51
Copy link
Member

@1117mg 1117mg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@earlgrey02 earlgrey02 merged commit 3c0795b into dev Feb 10, 2026
@earlgrey02 earlgrey02 deleted the feature/50-social-profile-sync branch February 10, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 기능 구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

소셜 프로필 연동 기능 구현

2 participants