Skip to content

feat: 예외 로직 분리#347

Merged
eunseo9311 merged 2 commits into
developfrom
fix/#346-apple-login-error
Mar 13, 2026
Merged

feat: 예외 로직 분리#347
eunseo9311 merged 2 commits into
developfrom
fix/#346-apple-login-error

Conversation

@pooreumjung
Copy link
Copy Markdown
Member

#️⃣ 346

📝 요약(Summary)

애플 로그인 이슈를 해결하기 위해서 정리했던 가정이 맞는지 확인하기 위해 로그인 예외 처리 분기

💬 공유사항 to 리뷰어

✅ PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

@pooreumjung pooreumjung self-assigned this Mar 13, 2026
@pooreumjung pooreumjung added bug 버그 fix 고치기 labels Mar 13, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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은 Apple 로그인 과정에서 발생할 수 있는 이메일 클레임 누락 문제를 해결하기 위해 예외 처리 로직을 개선합니다. 기존 사용자의 재로그인 시나리오와 신규 사용자의 로그인 시나리오를 명확히 구분하여 처리함으로써, Apple 로그인 안정성을 높이고 잠재적인 문제를 더 효과적으로 진단할 수 있도록 합니다.

Highlights

  • 애플 로그인 예외 처리 개선: Apple 로그인 시 이메일 클레임이 없는 경우에 대한 예외 처리 로직을 개선했습니다. 기존 사용자의 재로그인과 신규 사용자의 경우를 구분하여 처리합니다.
  • 신규 예외 코드 추가: 신규 Apple 사용자임에도 이메일 클레임이 없는 경우를 위한 NOT_FOUND_APPLE_EMAIL_NEW_USER 예외 코드를 추가했습니다.
  • 로깅 강화: 이메일 클레임이 없는 Apple 로그인 시나리오에 대한 상세 로깅을 추가하여 문제 진단에 도움을 줍니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/main/java/ssu/eatssu/domain/auth/entity/SystemAppleAuthenticator.java
    • UserRepository 의존성을 추가했습니다.
    • 로깅을 위해 @Slf4j 어노테이션을 추가했습니다.
    • JWT 클레임 파싱 중 ExpiredJwtException 발생 시 INVALID_IDENTITY_TOKEN 예외를 던지도록 try-catch 블록을 추가했습니다.
    • 이메일 클레임이 없는 경우, userRepository를 통해 기존 사용자인지 확인하는 로직을 추가했습니다.
    • 기존 사용자 재로그인 시나리오와 신규 사용자 시나리오에 대한 상세 로깅을 추가했습니다.
    • 신규 사용자이면서 이메일 클레임이 없는 경우 NOT_FOUND_APPLE_APPLE_EMAIL_NEW_USER 예외를 발생시키도록 변경했습니다.
  • src/main/java/ssu/eatssu/global/handler/response/BaseResponseStatus.java
    • 신규 Apple 사용자에게 이메일 클레임이 없는 경우를 위한 NOT_FOUND_APPLE_EMAIL_NEW_USER 예외 상태 코드를 추가했습니다.
Activity
  • 현재까지 PR에 대한 사람의 활동은 없습니다.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  1. 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

안녕하세요. Apple 로그인 예외 처리 로직 분리 작업에 대한 리뷰입니다. 재로그인 시나리오를 식별하기 위한 로직 분리는 좋은 시도이지만, 현재 구현은 재로그인하는 사용자의 로그인을 막는 심각한 버그를 포함하고 있습니다. 재로그인 시에는 예외를 발생시키는 대신, 데이터베이스에서 사용자 정보를 조회하여 로그인을 완료시켜야 합니다. 이에 대한 수정 제안을 코드와 함께 남겼습니다. 또한, 코드에 추가된 주석이 리포지토리 스타일 가이드를 따르도록 수정이 필요해 보입니다. 자세한 내용은 각 리뷰 코멘트를 확인해주세요.

Comment on lines 70 to 82
if (emailObj == null) {
throw new BaseException(NOT_FOUND_EMAIL);
boolean existsUser = userRepository.findByProviderId(providerId).isPresent();

if (existsUser) {
// 가설 맞음: 기존 유저 재로그인 케이스
log.info("[Apple Login] email claim 없음 & DB 유저 있음. 재로그인 케이스로 확인. providerId={}", providerId);
throw new BaseException(NOT_FOUND_EMAIL);
} else {
// 다른 원인: 신규 유저인데 email 없음 → 슬랙 알럿용 별도 에러코드
log.warn("[Apple Login] email claim 없음 & DB 유저 없음. 원인 불명. providerId={}", providerId);
throw new BaseException(NOT_FOUND_APPLE_EMAIL_NEW_USER);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

재로그인 시나리오에서 예외를 발생시키면 사용자가 다시 로그인할 수 없게 됩니다. Apple 정책에 따라 재로그인 시에는 이메일 클레임이 제공되지 않으므로, providerId를 사용하여 데이터베이스에서 기존 사용자를 조회해야 합니다.

사용자가 존재할 경우, 해당 사용자의 이메일 정보를 사용하여 OAuthInfo 객체를 생성하고 반환하여 로그인이 정상적으로 완료되도록 해야 합니다. 현재 구현은 재로그인 흐름을 중단시켜 버그를 유발할 수 있습니다.

또한, userRepository.findByProviderId(providerId) 호출이 불필요하게 두 번 발생할 수 있는 구조입니다. Optional<User>를 변수로 받아 처리하는 것이 더 효율적입니다.

아래와 같이 수정하는 것을 제안합니다. 이 제안을 적용하려면 ssu.eatssu.domain.user.entity.Userjava.util.Optional 클래스를 임포트해야 할 수 있습니다.

Suggested change
if (emailObj == null) {
throw new BaseException(NOT_FOUND_EMAIL);
boolean existsUser = userRepository.findByProviderId(providerId).isPresent();
if (existsUser) {
// 가설 맞음: 기존 유저 재로그인 케이스
log.info("[Apple Login] email claim 없음 & DB 유저 있음. 재로그인 케이스로 확인. providerId={}", providerId);
throw new BaseException(NOT_FOUND_EMAIL);
} else {
// 다른 원인: 신규 유저인데 email 없음 → 슬랙 알럿용 별도 에러코드
log.warn("[Apple Login] email claim 없음 & DB 유저 없음. 원인 불명. providerId={}", providerId);
throw new BaseException(NOT_FOUND_APPLE_EMAIL_NEW_USER);
}
}
if (emailObj == null) {
java.util.Optional<ssu.eatssu.domain.user.entity.User> userOptional = userRepository.findByProviderId(providerId);
if (userOptional.isPresent()) {
// 가설 맞음: 기존 유저 재로그인 케이스
log.info("[Apple Login] email claim 없음 & DB 유저 있음. 재로그인 케이스로 확인. providerId={}", providerId);
ssu.eatssu.domain.user.entity.User existingUser = userOptional.get();
return new OAuthInfo(existingUser.getEmail(), providerId);
} else {
// 다른 원인: 신규 유저인데 email 없음 → 슬랙 알럿용 별도 에러코드
log.warn("[Apple Login] email claim 없음 & DB 유저 없음. 원인 불명. providerId={}", providerId);
throw new BaseException(NOT_FOUND_APPLE_EMAIL_NEW_USER);
}
}

boolean existsUser = userRepository.findByProviderId(providerId).isPresent();

if (existsUser) {
// 가설 맞음: 기존 유저 재로그인 케이스
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

리포지토리 스타일 가이드 8번 규칙에 따르면, 주석에는 작성자 이름과 날짜가 포함되어야 합니다. 규칙에 맞게 수정해 주세요. 예: // [작성자, YYYY-MM-DD] 가설 맞음: 기존 유저 재로그인 케이스

References
  1. 리포지토리 스타일 가이드 8번 규칙: '각 주석에는 작성자의 이름과 날짜가 포함되어야 합니다.' 현재 주석은 이 형식을 따르지 않고 있습니다. (link)

log.info("[Apple Login] email claim 없음 & DB 유저 있음. 재로그인 케이스로 확인. providerId={}", providerId);
throw new BaseException(NOT_FOUND_EMAIL);
} else {
// 다른 원인: 신규 유저인데 email 없음 → 슬랙 알럿용 별도 에러코드
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

리포지토리 스타일 가이드 8번 규칙에 따르면, 주석에는 작성자 이름과 날짜가 포함되어야 합니다. 규칙에 맞게 수정해 주세요. 예: // [작성자, YYYY-MM-DD] 다른 원인: 신규 유저인데 email 없음 → 슬랙 알럿용 별도 에러코드

References
  1. 리포지토리 스타일 가이드 8번 규칙: '각 주석에는 작성자의 이름과 날짜가 포함되어야 합니다.' 현재 주석은 이 형식을 따르지 않고 있습니다. (link)

@pooreumjung pooreumjung requested a review from eunseo9311 March 13, 2026 12:58
Copy link
Copy Markdown
Contributor

@eunseo9311 eunseo9311 left a comment

Choose a reason for hiding this comment

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

LGTM

@eunseo9311 eunseo9311 merged commit 9e8cb85 into develop Mar 13, 2026
@eunseo9311 eunseo9311 deleted the fix/#346-apple-login-error branch March 13, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 버그 fix 고치기

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants