Skip to content

Commit

Permalink
feat: 인증코드 유효기간 변경 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
youngh0 authored Jun 4, 2024
1 parent 630e640 commit b724668
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
package com.parkingcomestrue.parking.application.auth;

import com.parkingcomestrue.common.domain.session.MemberSession;
import com.parkingcomestrue.common.domain.session.repository.MemberSessionRepository;
import com.parkingcomestrue.parking.application.auth.authcode.AuthCodeCategory;
import com.parkingcomestrue.parking.application.auth.authcode.AuthCodePlatform;
import com.parkingcomestrue.parking.application.auth.authcode.AuthCodeValidator;
import com.parkingcomestrue.parking.application.auth.authcode.dto.AuthCodeCertificateRequest;
import com.parkingcomestrue.parking.application.auth.authcode.dto.AuthCodeRequest;
import com.parkingcomestrue.parking.application.auth.authcode.dto.AuthCodeCreateEvent;
import com.parkingcomestrue.parking.application.auth.authcode.dto.AuthCodeRequest;
import com.parkingcomestrue.parking.application.auth.authcode.util.AuthCodeGenerator;
import com.parkingcomestrue.parking.application.auth.authcode.util.AuthCodeKeyConverter;
import com.parkingcomestrue.common.domain.session.MemberSession;
import com.parkingcomestrue.common.domain.session.repository.MemberSessionRepository;
import com.parkingcomestrue.parking.support.exception.ClientException;
import com.parkingcomestrue.parking.support.exception.ClientExceptionInformation;
import java.time.LocalDateTime;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

@RequiredArgsConstructor
@Service
public class AuthService {

private static final Long DURATION_MINUTE = 30L;

@Value("${authcode.expired-time}")
private Long authCodeExpired;

private final MemberSessionRepository memberSessionRepository;
private final AuthCodeGenerator authCodeGenerator;
private final AuthCodeValidator authCodeValidator;
Expand Down Expand Up @@ -66,7 +71,7 @@ public String createAuthCode(AuthCodeRequest authCodeRequest) {
String randomAuthCode = authCodeGenerator.generateAuthCode();
String authCodeKey = AuthCodeKeyConverter.convert(randomAuthCode, destination, authCodePlatform.getPlatform(),
authCodeCategory.getCategoryName());
redisTemplate.opsForValue().set(authCodeKey, randomAuthCode, 300L, TimeUnit.SECONDS);
redisTemplate.opsForValue().set(authCodeKey, randomAuthCode, authCodeExpired, TimeUnit.SECONDS);

publishAuthCodeCreateEvent(destination, authCodePlatform, authCodeCategory, randomAuthCode);
return randomAuthCode;
Expand Down
6 changes: 3 additions & 3 deletions app-api/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
spring:
profiles:
active: ${PROFILE:dev}
# MAIL
# MAIL
mail:
host: ${MAIL_HOST:smtp.gmail.com}
port: ${MAIL_PORT:587}
Expand All @@ -14,15 +14,15 @@ spring:
timeout: 5000
starttls:
enable: true
# REDIS
# REDIS
data:
redis:
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}

# AUTH CODE
authcode:
expired-time: 300
expired-time: 180

# Allow origin
cors:
Expand Down

0 comments on commit b724668

Please sign in to comment.