Skip to content
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

feat: 인증코드 유효기간 변경 #83

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading