File tree Expand file tree Collapse file tree 4 files changed +31
-2
lines changed
Expand file tree Collapse file tree 4 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 88import es .princip .ringus .domain .exception .SignUpErrorCode ;
99import es .princip .ringus .domain .member .MemberRepository ;
1010import es .princip .ringus .global .exception .CustomRuntimeException ;
11+ import jakarta .annotation .PostConstruct ;
1112import jakarta .servlet .http .HttpSession ;
1213import jakarta .transaction .Transactional ;
1314import lombok .RequiredArgsConstructor ;
15+ import org .springframework .beans .factory .annotation .Value ;
1416import org .springframework .stereotype .Service ;
1517
1618import java .util .Objects ;
@@ -24,6 +26,14 @@ public class EmailVerificationService {
2426 private final MemberRepository memberRepository ;
2527 private final EmailSendService emailSendService ;
2628
29+ @ Value ("${verification.max-failed-attempts}" )
30+ private int maxFailedAttempts ;
31+
32+ @ PostConstruct
33+ public void init (){
34+ EmailVerification .setMaxFailedAttempts (maxFailedAttempts );
35+ }
36+
2737 @ Transactional
2838 public void generateVerificationCode (String email ) {
2939 if (memberRepository .existsByEmail (email )){
Original file line number Diff line number Diff line change 55import lombok .NoArgsConstructor ;
66import org .springframework .data .annotation .Id ;
77import org .springframework .data .redis .core .RedisHash ;
8+
89import java .io .Serializable ;
910import java .util .Random ;
1011
@@ -26,6 +27,8 @@ public class EmailVerification implements Serializable {
2627
2728 private int failedAttempts ;
2829
30+ private static int maxFailedAttempts ;
31+
2932 public static EmailVerification of (String email ) {
3033 return new EmailVerification (email , generateVerificationCode ());
3134 }
@@ -45,10 +48,14 @@ public void plusFailedAttempts() {
4548 }
4649
4750 public boolean hasVerificationAttemptsLeft () {
48- return failedAttempts < 4 ;
51+ return failedAttempts < maxFailedAttempts ;
4952 }
5053
5154 public boolean isValid (String inputCode ) {
5255 return this .verificationCode .equals (inputCode );
5356 }
57+
58+ public static void setMaxFailedAttempts (int maxFailedAttempts ) {
59+ EmailVerification .maxFailedAttempts = maxFailedAttempts ;
60+ }
5461}
Original file line number Diff line number Diff line change 22
33import jakarta .servlet .http .Cookie ;
44import jakarta .servlet .http .HttpServletResponse ;
5+ import org .springframework .beans .factory .annotation .Value ;
6+ import org .springframework .stereotype .Component ;
57
68/**
79 * 쿠키 관련 유틸리티 클래스
810 * - 쿠키 생성 및 삭제 기능 제공
911 * - 보안 설정 적용 (HttpOnly, Secure)
1012 */
13+
14+ @ Component
1115public class CookieUtil {
1216
1317 /** 기본 쿠키 만료 시간 (30분) */
14- private static final int DEFAULT_EXPIRY = 60 * 30 ; // 30 minutes
18+ private static int DEFAULT_EXPIRY ;
19+
20+ public CookieUtil (@ Value ("${verification.default_expiry}" ) int DEFAULT_EXPIRY ) {
21+ CookieUtil .DEFAULT_EXPIRY = DEFAULT_EXPIRY ;
22+ }
1523
1624 /**
1725 * 쿠키를 생성하여 응답(Response)에 추가하는 메서드
Original file line number Diff line number Diff line change @@ -40,3 +40,7 @@ spring:
4040university :
4141 file :
4242 path : ${UNIVERSITY_FILE_PATH}
43+
44+ verification :
45+ max_failed_attempts : ${MAX_FAILED_ATTEMPTS}
46+ default_expiry : ${DEFAULT_EXPIRY}
You can’t perform that action at this time.
0 commit comments