Skip to content

Conversation

@seung-in-Yoo
Copy link
Member

@seung-in-Yoo seung-in-Yoo commented Jul 25, 2025

연관된 이슈

#68 , #58

작업 내용

  • 프론트 측의 요청에 따라 기존 회원가입 API에서 Request Body 필드 변경 (API 명세서 참고)
  • 회원가입 단계에서 최소 정보(이메일, 비밀번호, 로그인타입)만 받도록 변경
  • 닉네임, 성별 등 기타 개인정보는 "내 정보 등록" API로 분리 (추후 별도 구현 예정)
  • 유저 엔티티 수정 (nickname 등 null 허용)
  • 회원가입 로직 변경으로 인해서 바껴야하는 부분들 변경

테스트 결과

바뀐 회원가입 로직으로 swagger 테스트

화면 캡처 2025-07-25 235759

리뷰 요구사항 (선택)

회원가입 필드 로직 변경으로 인해서 테스트코드 유저쪽도 변경이 필요했습니다. 코드 확인 부탁드려요.

Summary by CodeRabbit

  • New Features

    • 카카오 로그인 시 액세스 토큰 필수 입력 검증이 추가되었습니다.
  • Refactor

    • 회원 가입 시 입력 필드가 이메일, 비밀번호, 로그인 방식으로 간소화되었습니다.
    • 닉네임, 이름, 생년월일, 성별, 회원 유형 입력 항목이 제거되었습니다.
    • 비밀번호 최소 길이 제한이 삭제되었습니다.
    • 회원 생성 로직과 관련 메서드가 단순화되고, 닉네임과 프로필 이미지 URL을 별도로 설정할 수 있도록 변경되었습니다.
    • 카카오 사용자 정보 DTO가 불변 객체로 변경되고, JSON 필드명과 Java 필드명이 일치하도록 개선되었습니다.
    • 인증된 사용자 ID 조회 시 타입 안전성과 예외 처리가 강화되었습니다.
  • Tests

    • 테스트 코드가 변경된 회원 생성 방식에 맞게 수정되었습니다.

@seung-in-Yoo seung-in-Yoo self-assigned this Jul 25, 2025
@seung-in-Yoo seung-in-Yoo added the 🔧 refactor 코드 리팩토링 label Jul 25, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 25, 2025

"""

Walkthrough

회원 가입 관련 DTO, 엔티티, 서비스, 카카오 로그인 서비스, 그리고 통합 테스트에서 사용자 생성 시 필수 입력값과 필드가 대폭 축소되었습니다. 닉네임, 이름, 생년월일, 성별, 사용자 유형 등이 제거되고, 이메일, 비밀번호, 로그인 유형만 필수로 남았습니다. 닉네임은 별도의 setter로 설정합니다. 또한, 카카오 로그인 서비스에서 ObjectMapper와 WebClient가 주입되고, 예외 처리 범위가 구체화되었습니다. 사용자 장소 컨트롤러에서는 인증된 사용자 ID 검증 로직이 명확해졌습니다.

Changes

파일/경로 변경 요약
.../user/dto/UserRegisterRequestDto.java nickname, username, birthDate, gender, userType 필드 및 유효성 검증 제거. password 최소 길이 검증 제거.
.../user/entity/User.java createUser 정적 팩토리 메서드 파라미터 축소 및 내부 빌더 수정. setNickname setter 추가. nickname nullable.
.../user/service/UserService.java signup 메서드에서 createUser 호출 시 전달 파라미터 축소. 내부 로직 단순화.
.../user/service/auth/KakaoLoginService.java ObjectMapper, WebClient 주입. fetchKakaoUserInfo 예외 처리 구체화. createUser 호출 파라미터 축소. nickname, 프로필 이미지 별도 설정. UserType import 제거.
.../user/dto/KakaoLoginRequestDto.java accessToken 필드에 @notblank 검증 추가 및 메시지 지정.
.../user/dto/KakaoUserInfoDto.java @Setter 제거로 불변화, 필드명 카멜케이스 변경 및 @JsonProperty 추가.
.../user/controller/UserPlaceController.java 인증 사용자 ID 추출 시 타입 체크 및 예외 처리 추가로 권한 검증 강화.
.../explore/WaybleZoneRecommendApiIntegrationTest.java 테스트 사용자 생성 시 createUser 파라미터 축소, nickname setter로 별도 설정. 이메일 형식 수정.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant UserService
    participant User

    Client->>UserService: 회원가입 요청(email, password, loginType)
    UserService->>User: User.createUser(email, password, loginType)
    User-->>UserService: User 객체 반환
    UserService-->>Client: 회원가입 처리 결과 반환
Loading
sequenceDiagram
    participant Kakao
    participant KakaoLoginService
    participant User

    Kakao->>KakaoLoginService: 카카오 로그인 요청
    KakaoLoginService->>User: User.createUser(email, "", LoginType.KAKAO)
    KakaoLoginService->>User: setNickname(nickname)
    KakaoLoginService->>User: updateProfileImageUrl(url)
    KakaoLoginService-->>Kakao: 로그인 처리 결과 반환
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇
필드가 줄고, 코드가 가벼워져
닉네임은 setter로 살짝 얹어
이메일, 비번, 로그인 타입만 남았네
테스트도, 서비스도 한결 단순해
토끼는 깡충, 리뷰도 깡충,
오늘은 코드가 산뜻한 봄날!
🌱
"""

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/seungin

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@seung-in-Yoo seung-in-Yoo linked an issue Jul 25, 2025 that may be closed by this pull request
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/main/java/com/wayble/server/user/entity/User.java (1)

88-90: 닉네임 setter 메서드 추가를 고려해보세요.

public setter는 캡슐화를 깨뜨릴 수 있지만 현재 리팩토링에는 필요합니다. 닉네임 유효성 검증을 추가하는 것을 고려해보세요.

 public void setNickname(String nickname) {
+    if (nickname != null && nickname.length() > 8) {
+        throw new IllegalArgumentException("닉네임은 8자를 초과할 수 없습니다");
+    }
     this.nickname = nickname;
 }
src/main/java/com/wayble/server/user/dto/UserRegisterRequestDto.java (1)

12-13: 비밀번호 유효성 검증 제거 검토 필요

비밀번호 최소 길이 검증이 제거되었습니다. 보안 요구사항에 따라 최소 길이나 복잡성 검증이 필요한지 검토해보세요.

 @NotBlank(message = "비밀번호는 필수입니다")
+@Size(min = 8, message = "비밀번호는 최소 8자 이상이어야 합니다")
 String password,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27028b9 and ac714be.

📒 Files selected for processing (5)
  • src/main/java/com/wayble/server/user/dto/UserRegisterRequestDto.java (1 hunks)
  • src/main/java/com/wayble/server/user/entity/User.java (2 hunks)
  • src/main/java/com/wayble/server/user/service/UserService.java (1 hunks)
  • src/main/java/com/wayble/server/user/service/auth/KakaoLoginService.java (2 hunks)
  • src/test/java/com/wayble/server/explore/WaybleZoneRecommendApiIntegrationTest.java (1 hunks)
🔇 Additional comments (8)
src/main/java/com/wayble/server/user/service/auth/KakaoLoginService.java (2)

45-50: 사용자 생성 로직 단순화가 잘 적용되었습니다.

카카오 소셜 로그인을 위한 사용자 생성이 새로운 패턴에 맞게 올바르게 수정되었습니다. 필수 정보만으로 사용자를 생성하고 닉네임을 별도로 설정하는 방식이 적절합니다.


60-60: Lombok @Getter로 getUserType() 자동 생성됨 확인

User.java 클래스에 클래스 레벨로 선언된 @Getter 어노테이션이 userType 필드의 getUserType() 메서드를 자동 생성하므로
user.getUserType().name() 호출은 정상입니다. 별도 수정이 필요 없습니다.

src/main/java/com/wayble/server/user/service/UserService.java (1)

24-28: 회원가입 로직 단순화가 올바르게 구현되었습니다.

필수 정보만으로 사용자를 생성하는 새로운 패턴이 정확히 적용되었습니다. 비밀번호 암호화와 중복 사용자 체크 로직이 그대로 유지되어 기존 기능이 보장됩니다.

src/test/java/com/wayble/server/explore/WaybleZoneRecommendApiIntegrationTest.java (2)

136-142: 테스트에서 사용자 생성 패턴이 올바르게 적용되었습니다.

새로운 사용자 생성 방식에 맞게 테스트 코드가 정확히 수정되었습니다. 이메일 형식도 개선되었고 닉네임을 별도로 설정하는 패턴이 일관되게 적용되었습니다.


152-154: 검증 결과: NPE 발생 우려 없음

  • AgeGroup.fromBirthDate(null) 호출 시 내부에서 if (birthDate == null) return OTHERS;로 처리하여 NPE 발생하지 않습니다.
  • User.createUser 빌더는 birthDate, gender를 설정하지 않아 두 필드가 null이지만, user.getGender()는 단순히 null을 반환할 뿐 메서드 호출로 인한 NPE가 발생하지 않습니다.

원 리뷰 코멘트의 null 참조 가능성 지적은 코드상에서 실제 예외를 일으키지 않으므로 무시해도 좋습니다.

Likely an incorrect or invalid review comment.

src/main/java/com/wayble/server/user/entity/User.java (2)

31-31: 닉네임 필드 nullable 처리가 올바르게 적용되었습니다.

새로운 회원가입 플로우에서 닉네임이 선택적 정보가 된 것에 맞게 데이터베이스 제약조건이 적절히 수정되었습니다.


71-82: 사용자 생성 팩토리 메서드 단순화가 효과적으로 구현되었습니다.

필수 정보만으로 사용자를 생성하는 새로운 요구사항에 맞게 createUser 메서드가 올바르게 단순화되었습니다. userType을 GENERAL로 기본 설정하는 것도 적절합니다.

src/main/java/com/wayble/server/user/dto/UserRegisterRequestDto.java (1)

7-17: 회원가입 DTO 단순화가 요구사항에 맞게 잘 구현되었습니다.

필수 정보만으로 회원가입을 처리하는 새로운 API 스펙에 맞게 DTO가 올바르게 단순화되었습니다. LoginType에 대한 주석도 API 문서화에 도움이 됩니다.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/main/java/com/wayble/server/user/controller/UserPlaceController.java (1)

66-73: 동일한 인증 로직 패턴 적용

saveUserPlace 메소드와 동일한 개선된 인증 로직이 일관성 있게 적용되었습니다. 타입 안전성과 예외 처리가 잘 구현되어 있습니다.

위에서 언급한 것처럼, 공통 유틸리티 메소드로 추출하면 코드 중복을 해결할 수 있습니다.

🧹 Nitpick comments (1)
src/main/java/com/wayble/server/user/controller/UserPlaceController.java (1)

40-47: 인증 로직 개선 - 타입 안전성 향상

Authentication 객체에서 principal을 안전하게 추출하는 로직이 잘 구현되었습니다. instanceof 체크를 통해 ClassCastException을 방지하고 명시적인 예외 처리를 추가한 점이 좋습니다.

하지만 동일한 패턴이 getUserPlaces 메소드에서도 반복되어 코드 중복이 발생합니다. 공통 유틸리티 메소드로 추출하는 것을 고려해보세요.

private Long getAuthenticatedUserId() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (!(authentication.getPrincipal() instanceof Long)) {
        throw new ApplicationException(UserErrorCase.FORBIDDEN);
    }
    return (Long) authentication.getPrincipal();
}

이후 각 메소드에서는 다음과 같이 사용할 수 있습니다:

Long tokenUserId = getAuthenticatedUserId();
if (!userId.equals(tokenUserId)) {
    throw new ApplicationException(UserErrorCase.FORBIDDEN);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6080736 and 8c5bad0.

📒 Files selected for processing (5)
  • src/main/java/com/wayble/server/user/controller/UserPlaceController.java (3 hunks)
  • src/main/java/com/wayble/server/user/dto/KakaoLoginRequestDto.java (1 hunks)
  • src/main/java/com/wayble/server/user/dto/KakaoUserInfoDto.java (1 hunks)
  • src/main/java/com/wayble/server/user/entity/User.java (2 hunks)
  • src/main/java/com/wayble/server/user/service/auth/KakaoLoginService.java (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/com/wayble/server/user/service/auth/KakaoLoginService.java
  • src/main/java/com/wayble/server/user/entity/User.java
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/java/com/wayble/server/user/dto/KakaoUserInfoDto.java (1)
src/main/java/com/wayble/server/user/entity/User.java (1)
  • Getter (14-91)
🔇 Additional comments (6)
src/main/java/com/wayble/server/user/dto/KakaoLoginRequestDto.java (1)

3-6: 유효성 검증 추가가 적절합니다.

카카오 로그인 요청에서 액세스 토큰에 대한 @NotBlank 유효성 검증 추가는 보안과 데이터 무결성 측면에서 중요한 개선사항입니다. 빈 문자열이나 공백만 있는 토큰을 사전에 차단하여 불필요한 API 호출을 방지할 수 있습니다.

src/main/java/com/wayble/server/user/controller/UserPlaceController.java (1)

14-14: Import 추가 승인

Authentication 인터페이스 import가 적절히 추가되었습니다.

src/main/java/com/wayble/server/user/dto/KakaoUserInfoDto.java (4)

5-5: 필요한 import 추가가 적절합니다.

@JsonProperty 어노테이션 사용을 위한 import 추가가 올바르게 되었습니다.


13-14: Java 네이밍 컨벤션 개선이 우수합니다.

필드명을 camelCase로 변경하면서 @JsonProperty 어노테이션으로 JSON 호환성을 유지한 점이 좋습니다. 코드 가독성이 향상되었습니다.


26-27: 일관된 네이밍 컨벤션 적용이 우수합니다.

profileImageUrl 필드명 변경이 kakaoAccount와 일관성 있게 적용되었고, User 엔티티의 updateProfileImageUrl() 메소드와도 네이밍이 일치합니다.


9-30: 전체적으로 우수한 리팩토링입니다.

이 변경사항들은 다음과 같은 장점을 제공합니다:

  • Java 네이밍 컨벤션 준수로 코드 가독성 향상
  • @JsonProperty를 통한 API 호환성 유지
  • 불변 객체 패턴 적용 (Setter 제거)으로 데이터 안정성 확보
  • 사용자 등록 API 리팩토링 목표와 일치하는 구조 개선

회원가입 및 카카오 로그인 리팩토링의 일환으로 적절한 변경입니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 회원가입 API 리팩토링

2 participants