Skip to content

fix: 학교 이메일 중복 인증을 차단한다#808

Open
Hexeong wants to merge 4 commits into
developfrom
fix/807-block-duplicated-email-auth
Open

fix: 학교 이메일 중복 인증을 차단한다#808
Hexeong wants to merge 4 commits into
developfrom
fix/807-block-duplicated-email-auth

Conversation

@Hexeong

@Hexeong Hexeong commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

관련 이슈

작업 내용

  • 학교 이메일 인증 완료 시 인증에 사용한 이메일을 verified_school_email로 저장하도록 사용자 도메인과 DB 마이그레이션을 추가했습니다.
  • 이미 인증 완료된 학교 이메일은 다른 계정에서 재사용할 수 없도록 요청 단계와 인증 확인 단계에서 중복 검증을 추가했습니다.
  • 동시 요청 등 애플리케이션 검증만으로 막기 어려운 케이스를 대비해 verified_school_email unique 제약과 저장 직후 flush 기반 예외 변환을 추가했습니다.
  • Redis 인증 정보가 손상된 경우 인증을 진행하지 않고 임시 인증 정보를 삭제하도록 검증 로직을 보강했습니다.
  • 학교 이메일 정규화, 인증 이메일 저장, 중복 인증 차단, unique 제약 검증 테스트를 추가했습니다.
  • 전체 테스트 실행 중 여러 테스트 컨텍스트의 조회수 스케줄러가 같은 Redis 키를 동시에 소비할 수 있는 경합을 확인해, 이미 소비된 조회수 Redis 키는 DB 업데이트를 건너뛰도록 방어 로직과 테스트를 추가했습니다.

특이 사항

  • site_user.verified_school_email은 nullable unique 컬럼입니다. 미인증 사용자는 NULL 상태로 유지되고, 인증 완료된 이메일만 중복 차단 대상이 됩니다.
  • 학교 이메일은 저장/검증 전에 trim + lowerCase로 정규화합니다.
  • bash gradlew test 전체 테스트 통과를 확인했습니다.

리뷰 요구사항 (선택)

  • verified_school_email unique 제약과 서비스 중복 검증이 함께 필요한 구조인지 확인 부탁드립니다.
  • 인증 요청과 인증 확인 양쪽에서 중복 검증하는 흐름, 그리고 DB unique 충돌을 SCHOOL_EMAIL_ALREADY_USED로 변환하는 방식이 적절한지 봐주세요.
  • 조회수 업데이트 스케줄러가 같은 Redis 키를 중복 처리하는 경우 null 카운트를 무시하는 방어 방식이 적절한지 확인 부탁드립니다.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

  1. 에러코드와 도메인 확장

    • SCHOOL_EMAIL_ALREADY_USED 에러코드가 추가됐고, SiteUserverifiedSchoolEmail 필드와 유니크 제약, verifySchool 시그니처 변경이 반영됐어요.
  2. 학교 이메일 인증 흐름 변경

    • SchoolEmailService가 이메일을 정규화하고, 중복 여부와 손상된 Redis 인증정보를 더 엄격하게 검사하도록 바뀌었어요.
  3. DB 반영과 테스트 보강

    • verified_school_email 컬럼/제약 마이그레이션이 추가됐고, 중복 저장·중복 인증·손상된 Redis 데이터에 대한 테스트가 보강됐어요.
  4. 조회수 업데이트 방어 로직

    • UpdateViewCountService가 Redis에서 읽은 조회수가 null이면 DB 증가 호출을 하지 않도록 바뀌었고, 이를 검증하는 테스트가 추가됐어요.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: wibaek, lsy1307, JAEHEE25

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning 조회수 Redis 경합 방어와 관련 테스트는 학교 이메일 인증 이슈와 무관한 추가 변경입니다. UpdateViewCountService 변경과 관련 테스트는 별도 PR로 분리해 이 이슈 범위에서 제외하세요.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed 인증 이메일 저장, 중복 차단, DB 유니크 제약, 정규화, 테스트 추가가 이슈 목표와 일치합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed 제목이 학교 이메일 중복 인증 차단이라는 핵심 변경을 간결하게 잘 요약합니다.
Description check ✅ Passed 관련 이슈, 작업 내용, 특이 사항, 리뷰 요구사항이 모두 포함되어 템플릿을 대부분 충족합니다.
✨ 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 fix/807-block-duplicated-email-auth

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/main/java/com/example/solidconnection/siteuser/service/SchoolEmailService.java (1)

87-93: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

flush 예외를 조금 더 좁혀서 잡아도 좋을 것 같아요.

DataIntegrityViolationException을 무조건 SCHOOL_EMAIL_ALREADY_USED로 변환하고 있는데, 현재 이 시점에 변경되는 필드가 verifiedSchoolEmail/homeUniversityId뿐이라 실질 위험은 낮지만, 향후 verifySchool 호출 전후로 다른 unique 제약이 걸린 필드가 같은 트랜잭션에서 변경되면 원인이 다른 무결성 위반도 같은 메시지로 감춰질 수 있습니다. 급하게 고칠 사항은 아니고 참고 삼아 남깁니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/example/solidconnection/siteuser/service/SchoolEmailService.java`
around lines 87 - 93, The flushVerifiedSchoolEmail method currently converts
every DataIntegrityViolationException into SCHOOL_EMAIL_ALREADY_USED, which can
hide unrelated unique-constraint failures. Narrow the handling by identifying
the specific integrity violation tied to verifiedSchoolEmail/homeUniversityId
inside SchoolEmailService, and only map that case to SCHOOL_EMAIL_ALREADY_USED
while letting other DataIntegrityViolationException cases propagate or be
handled separately.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/main/java/com/example/solidconnection/siteuser/service/SchoolEmailService.java`:
- Around line 87-93: The flushVerifiedSchoolEmail method currently converts
every DataIntegrityViolationException into SCHOOL_EMAIL_ALREADY_USED, which can
hide unrelated unique-constraint failures. Narrow the handling by identifying
the specific integrity violation tied to verifiedSchoolEmail/homeUniversityId
inside SchoolEmailService, and only map that case to SCHOOL_EMAIL_ALREADY_USED
while letting other DataIntegrityViolationException cases propagate or be
handled separately.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6e0e04b5-875b-4efe-8eee-7b4c3f5f51e8

📥 Commits

Reviewing files that changed from the base of the PR and between adcfb23 and c2042a6.

📒 Files selected for processing (7)
  • src/main/java/com/example/solidconnection/common/exception/ErrorCode.java
  • src/main/java/com/example/solidconnection/siteuser/domain/SiteUser.java
  • src/main/java/com/example/solidconnection/siteuser/repository/SiteUserRepository.java
  • src/main/java/com/example/solidconnection/siteuser/service/SchoolEmailService.java
  • src/main/resources/db/migration/V57__add_verified_school_email_to_site_user.sql
  • src/test/java/com/example/solidconnection/siteuser/repository/SiteUserRepositoryTest.java
  • src/test/java/com/example/solidconnection/siteuser/service/SchoolEmailServiceTest.java

@Hexeong Hexeong self-assigned this Jul 7, 2026
@Hexeong Hexeong added 버그 Something isn't working 리팩터링 최종 리뷰 최소 1명 필수 labels Jul 7, 2026

@wibaek wibaek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

이후 추가 PR로 SchoolEmailRequest@SiZe()와 verified_school_email 길이 검증 오류정도 추가하면 좋을 것 같습니다!
감사합니다!

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

Labels

리팩터링 버그 Something isn't working 최종 리뷰 최소 1명 필수

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 학교 이메일 인증 완료 시 인증 이메일을 저장해 중복 인증을 차단한다

2 participants