260826_01_ENH: 휴대전화 번호 인증 기능 추가
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.kri.notihub.server.config;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Validated
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "kri.sms.verification")
|
||||
public class PhoneVerificationProperties {
|
||||
|
||||
public static final String CODE_PLACEHOLDER = "#{verificationCode}";
|
||||
|
||||
@Min(1)
|
||||
private int expireMinutes = 5;
|
||||
|
||||
@Min(1)
|
||||
private int maxAttempts = 5;
|
||||
|
||||
@NotBlank
|
||||
private String messageTemplate = "인증번호는 [#{verificationCode}] 입니다.";
|
||||
|
||||
@PostConstruct
|
||||
void validateMessageTemplate() {
|
||||
int first = messageTemplate.indexOf(CODE_PLACEHOLDER);
|
||||
int last = messageTemplate.lastIndexOf(CODE_PLACEHOLDER);
|
||||
if (first < 0 || first != last) {
|
||||
throw new IllegalStateException(
|
||||
"kri.sms.verification.message-template must contain #{verificationCode} exactly once");
|
||||
}
|
||||
}
|
||||
|
||||
public String renderMessage(String verificationCode) {
|
||||
return messageTemplate.replace(CODE_PLACEHOLDER, verificationCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user