-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: [FN-4] 회원가입 #5
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
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
36706d0
Feat: 회원가입 시 비밀번호 유효성 검증 기능 추가
dungbik f04637f
Style: 코드 컨벤션에 맞지 않는 부분 수정
dungbik bbf72a6
Test: 비밀번호 유효성 검증기 단위 테스트
dungbik a56a9a1
Feat: 휴대전화 번호 하이픈(-) 제거 후 저장되도록 수정
dungbik 3fac57d
Feat: 회원가입시 휴대전화 번호 유효성 검증 기능 추가
dungbik f8aab93
Test: 휴대전화 번호 유효성 검증기 단위 테스트
dungbik 2a828a1
Feat: 이메일 인증번호 전송 기능
dungbik 5fcb801
Chore: application.yml 정리
dungbik 0c0ac3a
Chore: local용 docker-compose.yml 추가
dungbik d1d36a8
Feat: 이메일 인증번호 제출 기능
dungbik 2adf537
Fix: 검증 커스텀 어노테이션에 파라미터 누락 수정
dungbik 54a0cce
Feat: 회원가입시 인증된 이메일인지 검증하는 로직 추가
dungbik 567bb86
Chore: 잘못된 패키지 위치 정상화
dungbik 1981202
Feat: 휴대전화 번호 유효성 검증기 null 허용하도록 수정
dungbik 62a3fc4
Test: 회원가입 단위 테스트 작성
dungbik e8f4654
Test: 휴대전화 번호 유효성 검증기 단위 테스트 수정
dungbik 5d64418
Feat: 휴대전화 번호 null 도 가능하도록 수정
dungbik a4cb73b
Test: 휴대전화 번호 null일 때 회원가입 성공 테스트 케이스 추가
dungbik dec163c
Fix: 전화번호 중복 체크와 저장되는 값을 일관성 있게 처리
dungbik de5a4ad
Feat: 이메일 전송 재시도 로직에 재시도 횟수 명시적 설정 추가
dungbik 61f1fed
Feat: 스레드 풀 설정에 유효성 검증(@Min) 추가
dungbik 65d4d39
Feat: 레디스 키 생성시 args 유효성 검증 추가
dungbik 8a47f7c
Feat: Resend 설정에 유효성 검증(@NotEmpty) 추가
dungbik 4a533d0
Chore: JWT 시크릿 기본 값 삭제
dungbik 24a6aa0
Feat: 스레드 풀, Resend 설정 유효성 검증 수정
dungbik 51a9f8a
Chore: application-test.yml 에 jwt secret 추가
dungbik 68b6db4
Feat: 회원가입 하나의 트랜잭션으로 묶음
dungbik 9979018
Feat: 이메일 송신자와 템플릿 수정
dungbik b71ba66
Feat&Refactor: 이메일 인증번호 전송 메서드 라팩토링 및 이메일 존재 여부 체크 로직 추가
dungbik 461b512
Refactor: 인증번호 발급 여부 체크 중복 코드 제거
dungbik 4d2eeba
Refactor: AuthService 검증 로직 메서드로 추출
dungbik 19fc7fe
Fix: 이메일 인증번호 전송 실패시 로그 기록에서 인증번호 제거
dungbik d335090
Test: 이메일 인증번호 전송 단위 테스트 작성
dungbik e17e93d
refactor: 회원가입 단위 테스트 메서드명 간결하게 수정
dungbik 950a9fd
Test: 이메일 인증번호 전송 단위 테스트에서 인증번호 생성 로직 간접 테스트
dungbik db82650
Test: 이메일 인증번호 확인 단위 테스트 작성
dungbik 5503f7b
Refactor: UserRegisterDto 요청, 응답 별로 분리
dungbik 9caf7d6
Refactor: 이메일 인증관련 DTO 요청, 응답 별로 분리
dungbik 98b9df0
Feat: 휴대전화 암호화 적용
dungbik cf3a53e
Feat: AES 키 검증 로직
dungbik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| services: | ||
| flipnote-mysql: | ||
| image: mysql:latest | ||
| container_name: flipnote-mysql | ||
| ports: | ||
| - "3306:3306" | ||
| environment: | ||
| MYSQL_USERNAME: root | ||
| MYSQL_ROOT_PASSWORD: root | ||
| MYSQL_DATABASE: flipnote | ||
| TZ: Asia/Seoul | ||
|
|
||
| flipnote-redis: | ||
| image: redis:latest | ||
| container_name: flipnote-redis | ||
| ports: | ||
| - "6379:6379" |
15 changes: 15 additions & 0 deletions
15
src/main/java/project/flipnote/auth/constants/AuthRedisKey.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package project.flipnote.auth.constants; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import project.flipnote.common.constants.RedisKeys; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum AuthRedisKey implements RedisKeys { | ||
| EMAIL_CODE("auth:email:code:%s", VerificationConstants.CODE_TTL_MINUTES * 60), | ||
| EMAIL_VERIFIED("auth:email:verified:%s", 600); | ||
|
|
||
| private final String pattern; | ||
| private final int ttlSeconds; | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/main/java/project/flipnote/auth/constants/VerificationConstants.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package project.flipnote.auth.constants; | ||
|
|
||
| import lombok.AccessLevel; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public final class VerificationConstants { | ||
| public static final int CODE_LENGTH = 6; | ||
| public static final int CODE_TTL_MINUTES = 5; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/project/flipnote/auth/event/EmailVerificationSendEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package project.flipnote.auth.event; | ||
|
|
||
| public record EmailVerificationSendEvent( | ||
| String to, | ||
| String code | ||
| ) { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/project/flipnote/auth/listener/EmailVerificationEventListener.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package project.flipnote.auth.listener; | ||
|
|
||
| import org.springframework.context.event.EventListener; | ||
| import org.springframework.retry.annotation.Backoff; | ||
| import org.springframework.retry.annotation.Recover; | ||
| import org.springframework.retry.annotation.Retryable; | ||
| import org.springframework.scheduling.annotation.Async; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import project.flipnote.auth.constants.VerificationConstants; | ||
| import project.flipnote.auth.event.EmailVerificationSendEvent; | ||
| import project.flipnote.common.exception.EmailSendException; | ||
| import project.flipnote.infra.email.EmailService; | ||
|
|
||
| @Slf4j | ||
| @RequiredArgsConstructor | ||
| @Component | ||
| public class EmailVerificationEventListener { | ||
|
|
||
| private final EmailService emailService; | ||
|
|
||
| @Async | ||
| @Retryable( | ||
| maxAttempts = 3, | ||
| retryFor = { EmailSendException.class }, | ||
| backoff = @Backoff(delay = 2000, multiplier = 2) | ||
| ) | ||
| @EventListener | ||
| public void handleEmailVerificationSendEvent(EmailVerificationSendEvent event) { | ||
| emailService.sendEmailVerificationCode(event.to(), event.code(), VerificationConstants.CODE_TTL_MINUTES); | ||
| } | ||
|
|
||
| @Recover | ||
| public void recover(EmailSendException ex, EmailVerificationSendEvent event) { | ||
| log.error("이메일 인증번호 전송 3회 실패: to={}", event.to(), ex); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/project/flipnote/auth/model/EmailVerificationConfirmRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package project.flipnote.auth.model; | ||
|
|
||
| import jakarta.validation.constraints.Email; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
| import project.flipnote.auth.constants.VerificationConstants; | ||
|
|
||
| public record EmailVerificationConfirmRequest( | ||
|
|
||
| @Email @NotBlank | ||
| String email, | ||
|
|
||
| @NotBlank | ||
| @Size(min = VerificationConstants.CODE_LENGTH, max = VerificationConstants.CODE_LENGTH) | ||
| String code | ||
| ) { | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/project/flipnote/auth/model/EmailVerificationRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package project.flipnote.auth.model; | ||
|
|
||
| import jakarta.validation.constraints.Email; | ||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record EmailVerificationRequest( | ||
|
|
||
| @Email @NotBlank | ||
| String email | ||
| ) { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/project/flipnote/auth/repository/EmailVerificationRedisRepository.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package project.flipnote.auth.repository; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.Optional; | ||
|
|
||
| import org.springframework.data.redis.core.RedisTemplate; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import project.flipnote.auth.constants.AuthRedisKey; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Repository | ||
| public class EmailVerificationRedisRepository { | ||
|
|
||
| private final RedisTemplate<String, String> emailRedisTemplate; | ||
|
|
||
| public void saveCode(String email, String code) { | ||
| String key = AuthRedisKey.EMAIL_CODE.key(email); | ||
| Duration ttl = AuthRedisKey.EMAIL_CODE.getTtl(); | ||
|
|
||
| emailRedisTemplate.opsForValue().set(key, code, ttl); | ||
| } | ||
|
|
||
| public boolean existCode(String email) { | ||
| String key = AuthRedisKey.EMAIL_CODE.key(email); | ||
|
|
||
| return emailRedisTemplate.hasKey(key); | ||
| } | ||
|
|
||
| public Optional<String> findCode(String email) { | ||
| String key = AuthRedisKey.EMAIL_CODE.key(email); | ||
|
|
||
| String code = emailRedisTemplate.opsForValue().get(key); | ||
|
|
||
| return Optional.ofNullable(code); | ||
| } | ||
|
|
||
| public void deleteCode(String email) { | ||
| String key = AuthRedisKey.EMAIL_CODE.key(email); | ||
|
|
||
| emailRedisTemplate.delete(key); | ||
| } | ||
|
|
||
| public void markAsVerified(String email) { | ||
| String key = AuthRedisKey.EMAIL_VERIFIED.key(email); | ||
| Duration ttl = AuthRedisKey.EMAIL_VERIFIED.getTtl(); | ||
|
|
||
| emailRedisTemplate.opsForValue().set(key, "1", ttl); | ||
| } | ||
|
|
||
| public boolean isVerified(String email) { | ||
| String key = AuthRedisKey.EMAIL_VERIFIED.key(email); | ||
|
|
||
| return emailRedisTemplate.hasKey(key); | ||
| } | ||
|
|
||
| public void deleteVerified(String email) { | ||
| String key = AuthRedisKey.EMAIL_VERIFIED.key(email); | ||
|
|
||
| emailRedisTemplate.delete(key); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.