From 7ac21fd19e19b6fffa0eec1f740bd8b4ce5376d6 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn <91878695+uwoobeat@users.noreply.github.com> Date: Fri, 1 Mar 2024 22:33:21 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=EC=97=94=ED=8B=B0=ED=8B=B0=20?= =?UTF-8?q?=EB=B9=8C=EB=8D=94=EC=97=90=20=EB=8C=80=ED=95=B4=20private=20?= =?UTF-8?q?=EC=A0=91=EA=B7=BC=20=EC=A0=9C=EC=96=B4=EC=9E=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#215)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 엔티티 빌더에 비공개 접근제어자 추가 * fix: 리프레시 토큰에 대한 정적 팩토리 메서드 추가 --- .../gdsc/domain/auth/application/JwtService.java | 8 +++----- .../gdschongik/gdsc/domain/auth/domain/RefreshToken.java | 9 +++++++-- .../domain/discord/domain/DiscordVerificationCode.java | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/auth/application/JwtService.java b/src/main/java/com/gdschongik/gdsc/domain/auth/application/JwtService.java index 73811cbe9..4a9d96c1e 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/auth/application/JwtService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/auth/application/JwtService.java @@ -33,11 +33,9 @@ public RefreshTokenDto createRefreshToken(Long memberId) { } private void saveRefreshTokenToRedis(RefreshTokenDto refreshTokenDto) { - RefreshToken refreshToken = RefreshToken.builder() - .memberId(refreshTokenDto.memberId()) - .token(refreshTokenDto.tokenValue()) - .ttl(refreshTokenDto.ttl()) - .build(); + RefreshToken refreshToken = + RefreshToken.create(refreshTokenDto.memberId(), refreshTokenDto.tokenValue(), refreshTokenDto.ttl()); + refreshTokenRepository.save(refreshToken); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/auth/domain/RefreshToken.java b/src/main/java/com/gdschongik/gdsc/domain/auth/domain/RefreshToken.java index 83dfcb61e..d89d2d6b2 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/auth/domain/RefreshToken.java +++ b/src/main/java/com/gdschongik/gdsc/domain/auth/domain/RefreshToken.java @@ -1,5 +1,6 @@ package com.gdschongik.gdsc.domain.auth.domain; +import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import org.springframework.data.annotation.Id; @@ -18,10 +19,14 @@ public class RefreshToken { @TimeToLive private long ttl; - @Builder - public RefreshToken(Long memberId, String token, long ttl) { + @Builder(access = AccessLevel.PRIVATE) + private RefreshToken(Long memberId, String token, long ttl) { this.memberId = memberId; this.token = token; this.ttl = ttl; } + + public static RefreshToken create(Long memberId, String token, long ttl) { + return RefreshToken.builder().memberId(memberId).token(token).ttl(ttl).build(); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/discord/domain/DiscordVerificationCode.java b/src/main/java/com/gdschongik/gdsc/domain/discord/domain/DiscordVerificationCode.java index f7a7034cc..87cd109f3 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/discord/domain/DiscordVerificationCode.java +++ b/src/main/java/com/gdschongik/gdsc/domain/discord/domain/DiscordVerificationCode.java @@ -2,6 +2,7 @@ import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.global.exception.ErrorCode; +import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import org.springframework.data.annotation.Id; @@ -23,7 +24,7 @@ public class DiscordVerificationCode { @TimeToLive private Long ttl; - @Builder + @Builder(access = AccessLevel.PRIVATE) private DiscordVerificationCode(String discordUsername, Integer code, Long ttl) { validateCodeRange(code); this.discordUsername = discordUsername; From f40451da2daea55c403c314f155af959c8ba7db5 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn <91878695+uwoobeat@users.noreply.github.com> Date: Sat, 2 Mar 2024 00:03:31 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=202=EC=B0=A8=20=EB=AA=A8=EC=A7=91?= =?UTF-8?q?=EA=B8=B0=EA=B0=84=20=EC=9D=B4=EC=A0=84=20=EC=83=88=EB=A1=9C=20?= =?UTF-8?q?=EA=B0=80=EC=9E=85=ED=95=9C=20=EB=A9=A4=EB=B2=84=EB=8A=94=20?= =?UTF-8?q?=EB=8C=80=EA=B8=B0=20=ED=8E=98=EC=9D=B4=EC=A7=80=EB=A1=9C=20?= =?UTF-8?q?=EB=9E=9C=EB=94=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20(#217)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: 대기 페이지 랜딩 로직 구현 --- .../gdsc/global/security/LandingStatus.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/global/security/LandingStatus.java b/src/main/java/com/gdschongik/gdsc/global/security/LandingStatus.java index abaf7f122..3abc80e72 100644 --- a/src/main/java/com/gdschongik/gdsc/global/security/LandingStatus.java +++ b/src/main/java/com/gdschongik/gdsc/global/security/LandingStatus.java @@ -1,14 +1,24 @@ package com.gdschongik.gdsc.global.security; import com.gdschongik.gdsc.domain.member.domain.Member; +import java.time.LocalDate; +import java.time.LocalDateTime; public enum LandingStatus { + ONBOARDING_NOT_OPENED, // 대기 페이지로 랜딩 TO_STUDENT_AUTHENTICATION, // 재학생 인증 페이지로 랜딩 TO_REGISTRATION, // 가입신청 페이지로 랜딩 TO_DASHBOARD, // 대시보드로 랜딩 ; public static LandingStatus of(Member member) { + // 1차 모집기간 종료 ~ 2차 모집기간 시작 사이 가입했고, 현재는 2차 모집기간이 아닐 때 대기 페이지로 랜딩 + if (member.getCreatedAt().isAfter(Constants.FIRST_RECRUITMENT_END_DATE.atStartOfDay()) + && member.getCreatedAt().isBefore(Constants.SECOND_RECRUITMENT_START_DATE.atStartOfDay()) + && LocalDateTime.now().isBefore(Constants.SECOND_RECRUITMENT_START_DATE.atStartOfDay())) { + return ONBOARDING_NOT_OPENED; + } + // 아직 재학생 인증을 하지 않았다면 재학생 인증 페이지로 랜딩 if (!member.getRequirement().isUnivVerified()) { return TO_STUDENT_AUTHENTICATION; @@ -23,4 +33,9 @@ public static LandingStatus of(Member member) { // 재학생 인증과 가입신청을 모두 완료했다면 대시보드로 랜딩 return TO_DASHBOARD; } + + private static class Constants { + private static final LocalDate FIRST_RECRUITMENT_END_DATE = LocalDate.of(2024, 3, 2); + private static final LocalDate SECOND_RECRUITMENT_START_DATE = LocalDate.of(2024, 3, 4); + } }