-
Notifications
You must be signed in to change notification settings - Fork 1
[배포] KMC 회원, 카카오 중복 회원가입 에러 처리 #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
MOSU-341 refactor: 카카오 회원 중복 시 에러 처리
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @wlgns12370, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
이 PR은 KMC 회원 및 카카오 사용자의 중복 회원가입 오류를 처리하기 위한 변경 사항을 포함합니다. 기존 모수 사용자가 전화번호를 통해 식별될 경우 OAuth 예외를 발생시키고, OAuth 로그인 실패 시 특정 오류 유형에 따라 적절한 응답을 반환하도록 오류 처리 로직을 개선합니다.
Highlights
- 커스텀 OAuth 예외 도입: OAuth 관련 오류를 명확하게 처리하기 위해 새로운 OAuthException이 추가되었습니다.
- 중복 회원가입 확인: OAuthUserPersistenceProcessor는 이제 전화번호로 기존 사용자를 찾을 때 해당 사용자가 이미 모수 회원인 경우 "DUPLICATE" 메시지와 함께 OAuthException을 발생시킵니다.
- OAuth 로그인 실패 처리 개선: OAuth2LoginFailureHandler가 업데이트되어 다양한 OAuth 오류 유형(CANCELED, DUPLICATE, UNKNOWN)을 처리하고, 적절한 오류 코드를 포함하는 구조화된 OAuthFailureResponse를 반환합니다.
- 새로운 오류 유형 Enum: OAuthErrorType enum이 추가되어 특정 오류 메시지를 미리 정의된 유형으로 분류하고 매핑합니다.
- 새로운 실패 응답 레코드: OAuthFailureResponse 레코드가 도입되어 OAuth 로그인 실패 시 반환되는 응답 형식을 표준화합니다.
- 사용되지 않는 LoginResponse 메서드 제거: LoginResponse 클래스에서 null 값을 반환하던 불필요한 from() 메서드가 제거되었습니다.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
안녕하세요. KMC 회원 및 카카오 중복 회원가입 에러 처리를 위한 변경사항 잘 보았습니다. 커스텀 예외와 실패 핸들러를 도입하여 OAuth 로그인 실패 로직을 체계적으로 구현하신 점이 좋습니다. 코드의 안정성과 유지보수성을 높일 수 있는 몇 가지 개선점을 제안드립니다.
| return switch (text) { | ||
| case "DUPLICATE" -> DUPLICATE; | ||
| case "[access_denied] User denied access" -> CANCELED; | ||
| default -> UNKNOWN; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 from 메소드는 예외 메시지 문자열 "[access_denied] User denied access"에 직접 의존하고 있어, Spring Security 버전 변경 등에 따라 메시지가 바뀌면 코드가 오작동할 위험이 있습니다. 보다 안정적인 방법은 OAuth2LoginFailureHandler에서 exception 객체의 타입을 확인하여 OAuth2AuthenticationException인 경우 getError().getErrorCode()를 통해 access_denied와 같은 에러 코드를 얻어오고, 그 코드를 이 from 메소드에 전달하는 것입니다. 이렇게 하면 외부 라이브러리의 메시지 변경에 영향을 받지 않는 견고한 코드를 만들 수 있습니다.
아래와 같이 from 메소드를 수정하고, OAuth2LoginFailureHandler도 함께 수정하는 것을 권장합니다.
OAuth2LoginFailureHandler.java 수정 예시:
String message = exception.getMessage();
if (exception instanceof org.springframework.security.oauth2.core.OAuth2AuthenticationException e) {
message = e.getError().getErrorCode();
}
OAuthErrorType errorType = OAuthErrorType.from(message);| return switch (text) { | |
| case "DUPLICATE" -> DUPLICATE; | |
| case "[access_denied] User denied access" -> CANCELED; | |
| default -> UNKNOWN; | |
| }; | |
| return switch (text) { | |
| case "DUPLICATE" -> DUPLICATE; | |
| case "access_denied" -> CANCELED; | |
| default -> UNKNOWN; | |
| }; |
| default -> UNKNOWN; | ||
| }; | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public static OAuthFailureResponse from(String errorCode) { | ||
| return new OAuthFailureResponse(null, errorCode); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isProfileRegistered 필드에 null을 반환하는 것은 클라이언트 측에서 NullPointerException을 유발할 수 있습니다. 로그인 실패 시에는 프로필이 등록되지 않은 상태이므로, null 대신 false를 명시적으로 반환하여 API 응답의 명확성을 높이고 잠재적인 오류를 방지하는 것이 좋습니다.
| public static OAuthFailureResponse from(String errorCode) { | |
| return new OAuthFailureResponse(null, errorCode); | |
| } | |
| public static OAuthFailureResponse from(String errorCode) { | |
| return new OAuthFailureResponse(false, errorCode); | |
| } |
No description provided.