Skip to content

Commit

Permalink
v1.3.0 (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
uwoobeat authored Mar 1, 2024
2 parents f3e87b9 + f40451d commit d09843a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
}

0 comments on commit d09843a

Please sign in to comment.