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

Refactor/23: 시간 설정 및 유효기간 수정 #24

Merged
merged 2 commits into from
Aug 5, 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
8 changes: 5 additions & 3 deletions src/main/java/com/cmc/suppin/global/config/MailConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

@Component
Expand All @@ -26,8 +27,9 @@ public boolean sendMail(String toEmail, String code) {
helper.setSubject("Suppin 인증번호");

// Format the current date and time
String formattedDateTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd, HH:mm"));

String formattedDateTime = ZonedDateTime.now(ZoneId.of("Asia/Seoul"))
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd, HH:mm"));

// Use StringBuilder to construct the HTML email body
StringBuilder emailBody = new StringBuilder();
emailBody.append("<!DOCTYPE html>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ResponseEntity<ApiResponse<Void>> requestEmailAuth(@RequestBody @Valid Me

// 이메일 인증번호 확인(회원가입 시)
@PostMapping("/join/email/verification")
@Operation(summary = "이메일 인증번호 확인 API", description = "request : email, verificationCode, response: 인증번호 일치 시 true, 불일치 시 false")
@Operation(summary = "이메일 인증번호 확인 API", description = "request : email, verificationCode(인증번호 유효기간은 5분입니다.), response: 인증번호 일치 시 true, 불일치 시 false")
public ResponseEntity<ApiResponse<Void>> verifyEmailCode(@RequestBody @Valid MemberRequestDTO.EmailVerificationDTO request) {
memberService.verifyEmailCode(request.getEmail(), request.getVerificationCode());
return ResponseEntity.ok(ApiResponse.confirm(ResponseCode.CONFIRM));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private void saveVerificationToken(String email, String code) {
EmailVerificationToken verificationToken = EmailVerificationToken.builder()
.email(email)
.token(code)
.expiryDate(LocalDateTime.now().plusHours(1))
.expiryDate(LocalDateTime.now().plusMinutes(5))
.build();

emailVerificationTokenRepository.deleteByEmail(email);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
spring:
server:
port: 8080
jackson:
time-zone: Asia/Seoul
datasource:
url: ${DB_URL}
username: ${DB_USER}
Expand Down
Loading