Skip to content

Commit c2b2ef4

Browse files
committed
fix[email]: 랜덤 인스턴스 객체화
1 parent 7863b62 commit c2b2ef4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

backend/src/main/java/com/ai/lawyer/global/email/service/EmailAuthService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ public class EmailAuthService {
1313

1414
private final RedisTemplate<String, Object> redisTemplate;
1515
private static final long EXPIRATION_MINUTES = 5; // 인증번호 유효시간 (5분)
16+
private static final Random RANDOM = new Random(); // Random 인스턴스 재사용
1617

1718
/**
1819
* 인증번호 생성 후 Redis에 저장
1920
*/
2021
public String generateAndSaveAuthCode(String loginId) {
21-
String code = String.format("%06d", new Random().nextInt(999999)); // 6자리 랜덤 숫자
22+
String code = String.format("%06d", RANDOM.nextInt(999999)); // 6자리 랜덤 숫자
2223
redisTemplate.opsForValue().set(buildKey(loginId), code, EXPIRATION_MINUTES, TimeUnit.MINUTES);
2324
return code;
2425
}

0 commit comments

Comments
 (0)