Skip to content

feat: #261 회원가입 시 이메일 인증#273

Merged
FLYLIKEB merged 2 commits intomainfrom
feature/issue-261-email-verification
Mar 16, 2026
Merged

feat: #261 회원가입 시 이메일 인증#273
FLYLIKEB merged 2 commits intomainfrom
feature/issue-261-email-verification

Conversation

@FLYLIKEB
Copy link
Copy Markdown
Owner

@FLYLIKEB FLYLIKEB commented Mar 16, 2026

Summary

  • Closes [Feature] 회원가입 시 이메일 인증 #261
  • 회원가입 시 이메일 인증 토큰 발송
  • POST /api/auth/verify-email, POST /api/auth/resend-verification 엔드포인트
  • EmailVerifiedGuard로 미인증 사용자 노트 작성 차단
  • 기존 사용자는 emailVerifiedAt = createdAt로 백필
  • VerifyEmail 페이지, EmailVerificationBanner 컴포넌트

Test plan

  • npm run build
  • npm run test:run
  • cd backend && npm run build && npm run test

Summary by CodeRabbit

Release Notes

  • New Features

    • 이메일 검증 시스템 추가 - 회원가입 후 이메일 검증 필수
    • 검증 페이지(/verify-email) 신규 추가
    • 검증 배너로 미확인 사용자에게 알림 제공
    • 검증 토큰 재발송 기능 추가
    • 이메일 검증 완료 전까지 일부 기능(노트 작성 등) 제한
  • Tests

    • 이메일 검증 흐름 종단 간 테스트 추가
    • 검증 페이지 및 배너 단위 테스트 추가

FLYLIKEB and others added 2 commits March 16, 2026 17:47
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cha-log Ready Ready Preview, Comment Mar 16, 2026 8:51am

@FLYLIKEB FLYLIKEB merged commit e95a462 into main Mar 16, 2026
2 checks passed
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 16, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f0ef9ec1-7662-4b68-81b3-6f0546e1fba2

📥 Commits

Reviewing files that changed from the base of the PR and between beea740 and 3c2e1e8.

📒 Files selected for processing (26)
  • .claude/rules/testing.md
  • backend/migrations/1813000000000-AddEmailVerification.ts
  • backend/src/auth/auth.controller.ts
  • backend/src/auth/auth.module.ts
  • backend/src/auth/auth.service.spec.ts
  • backend/src/auth/auth.service.ts
  • backend/src/auth/dto/verify-email.dto.ts
  • backend/src/auth/entities/email-verification-token.entity.ts
  • backend/src/auth/guards/email-verified.guard.ts
  • backend/src/mail/mail.service.ts
  • backend/src/notes/notes.controller.ts
  • backend/src/notes/notes.module.ts
  • backend/src/users/entities/user.entity.ts
  • backend/src/users/users.service.ts
  • backend/test/app.e2e-spec.ts
  • backend/test/jest-e2e.json
  • backend/test/setup/test-setup.ts
  • backend/test/suites/auth-email-verification.e2e-spec.ts
  • src/App.tsx
  • src/components/EmailVerificationBanner.tsx
  • src/components/__tests__/EmailVerificationBanner.test.tsx
  • src/contexts/AuthContext.tsx
  • src/lib/api/auth.api.ts
  • src/pages/Register.tsx
  • src/pages/VerifyEmail.tsx
  • src/pages/__tests__/VerifyEmail.test.tsx

워크스루

이메일 인증 기능을 구현하는 종합적인 변경사항입니다. 회원가입 시 인증 토큰을 생성하고 인증 메일을 발송하며, 사용자가 토큰을 통해 이메일을 인증할 수 있도록 합니다. 인증되지 않은 사용자는 노트 작성을 제한받습니다.

변경사항

Cohort / File(s) 요약
데이터베이스 마이그레이션
.claude/rules/testing.md, backend/migrations/1813000000000-AddEmailVerification.ts, backend/test/setup/test-setup.ts
email_verification_tokens 테이블 생성, users 테이블에 emailVerifiedAt 컬럼 추가, 기존 데이터 마이그레이션, 테스트 정리 순서 업데이트
엔티티 및 모듈 구성
backend/src/auth/entities/email-verification-token.entity.ts, backend/src/users/entities/user.entity.ts, backend/src/auth/auth.module.ts
EmailVerificationToken 엔티티 추가, User 엔티티에 emailVerifiedAt 필드 추가, 모듈에 EmailVerificationToken 등록
인증 서비스 로직
backend/src/auth/auth.service.ts, backend/src/auth/auth.service.spec.ts
verifyEmail, resendVerification 메서드 추가, 회원가입 시 인증 메일 발송, 사용자 응답에 emailVerifiedAt 포함, 테스트 모듈 확장
인증 컨트롤러 및 DTO
backend/src/auth/auth.controller.ts, backend/src/auth/dto/verify-email.dto.ts
POST /auth/verify-email, POST /auth/resend-verification 엔드포인트 추가, VerifyEmailDto 검증 추가
인증 가드
backend/src/auth/guards/email-verified.guard.ts
이메일 미인증 사용자 접근 제어를 위한 EmailVerifiedGuard 추가
메일 서비스
backend/src/mail/mail.service.ts
sendVerificationEmail 메서드 추가, 인증 URL 포함 메일 발송
노트 모듈
backend/src/notes/notes.controller.ts, backend/src/notes/notes.module.ts
노트 작성 시 EmailVerifiedGuard 적용, UsersModule 임포트
사용자 서비스
backend/src/users/users.service.ts
updateEmailVerifiedAt 메서드 추가
백엔드 E2E 테스트
backend/test/app.e2e-spec.ts, backend/test/suites/auth-email-verification.e2e-spec.ts, backend/test/jest-e2e.json
포괄적인 이메일 인증 E2E 테스트 스위트 추가
프론트엔드 컨텍스트 및 API
src/contexts/AuthContext.tsx, src/lib/api/auth.api.ts
User 인터페이스에 emailVerifiedAt 필드 추가, verifyEmail, resendVerification API 메서드 추가
프론트엔드 페이지
src/pages/Register.tsx, src/pages/VerifyEmail.tsx, src/pages/__tests__/VerifyEmail.test.tsx
회원가입 후 인증 페이지로 자동 이동, VerifyEmail 페이지 추가, 컴포넌트 테스트 추가
프론트엔드 컴포넌트
src/App.tsx, src/components/EmailVerificationBanner.tsx, src/components/__tests__/EmailVerificationBanner.test.tsx
VerifyEmail 라우트 추가, 미인증 사용자용 배너 컴포넌트 추가, 컴포넌트 테스트 추가

시퀀스 다이어그램

sequenceDiagram
    participant User as 사용자
    participant Frontend as 프론트엔드
    participant Backend as 백엔드 (Auth)
    participant Mail as 메일 서비스
    participant DB as 데이터베이스

    User->>Frontend: 회원가입 (이메일, 비밀번호)
    Frontend->>Backend: POST /auth/register
    Backend->>DB: 새 사용자 생성 (emailVerifiedAt = null)
    Backend->>Backend: 토큰 생성 및 해싱
    Backend->>DB: email_verification_tokens 저장
    Backend->>Mail: 인증 토큰으로 이메일 발송
    Mail-->>User: 인증 링크 메일 수신
    Frontend->>Frontend: /verify-email로 이동
    User->>Frontend: 메일의 링크 클릭 또는 토큰 입력
    Frontend->>Backend: POST /auth/verify-email {token}
    Backend->>DB: 토큰 조회 및 검증
    alt 토큰 유효
        Backend->>DB: emailVerifiedAt = now()로 업데이트
        Backend->>DB: 토큰을 used 표시
        Backend-->>Frontend: 201 Success
        Frontend->>User: 인증 완료 메시지
    else 토큰 무효/만료
        Backend-->>Frontend: 400 Bad Request
        Frontend->>User: 오류 표시 및 재발송 옵션
    end
Loading
sequenceDiagram
    participant User as 사용자
    participant Frontend as 프론트엔드
    participant Backend as 백엔드 (Auth)
    participant Mail as 메일 서비스
    participant DB as 데이터베이스

    User->>Frontend: 노트 작성 시도
    Frontend->>Backend: POST /notes {content}
    Backend->>Backend: JwtAuthGuard 검증
    Backend->>Backend: EmailVerifiedGuard 검증
    alt emailVerifiedAt 있음
        Backend->>DB: 노트 생성
        Backend-->>Frontend: 201 Created
    else emailVerifiedAt 없음
        Backend-->>Frontend: 403 Forbidden
        Frontend->>User: 이메일 인증 필요 안내
        User->>Frontend: 재발송 버튼 클릭
        Frontend->>Backend: POST /auth/resend-verification
        Backend->>DB: 기존 토큰 무효화
        Backend->>Backend: 새 토큰 생성
        Backend->>DB: 새 토큰 저장
        Backend->>Mail: 새 인증 이메일 발송
        Mail-->>User: 새 인증 링크 메일
    end
Loading

예상 코드 리뷰 난이도

🎯 4 (복잡함) | ⏱️ ~50분

관련 가능성 있는 PR

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/issue-261-email-verification
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 회원가입 시 이메일 인증

1 participant