Skip to content

Commit

Permalink
chore: 인증 실패시 로깅 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
23tae committed Dec 6, 2024
1 parent a7ffe17 commit bb567ec
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,21 @@ class EmailVerificationService(
validateVerificationAttempts(email)
incrementVerificationAttempts(email)
// Redis에서 인증 코드 조회
val redisCode = getVerificationCode(email)
val redisCode = getVerificationCode(email, requestInfo)
// 인증 코드 검증
validateVerificationCode(redisCode, code, email, requestInfo)
// 검증 성공한 코드 삭제
clearVerificationData(email)
}

private fun getVerificationCode(email: String): String {
private fun getVerificationCode(email: String, requestInfo: RequestInfoDto): String {
val verificationCodeKey =
VerificationUtils.generateRedisKey(VerificationConstants.CODE_PREFIX, email)
val code = redisTemplate.opsForValue().get(verificationCodeKey)
code ?: throw EmailVerificationCodeExpiredException()
if (code == null) {
logger.warn("[이메일 인증 실패(만료)] email: $email, $requestInfo")
throw EmailVerificationCodeExpiredException()
}
return code.toString()
}

Expand All @@ -77,7 +80,7 @@ class EmailVerificationService(
requestInfo: RequestInfoDto
) {
if (redisCode != code) {
logger.warn("[이메일 인증 실패] email: $email, $requestInfo")
logger.warn("[이메일 인증 실패(불일치)] email: $email, $requestInfo")
throw EmailVerificationCodeMismatchException()
}
logger.info("[이메일 인증 성공] email: $email")
Expand Down

0 comments on commit bb567ec

Please sign in to comment.