fix(auth): disable fixed SMS codes in prod
This commit is contained in:
@@ -62,14 +62,11 @@ public class CaptchaController {
|
||||
|
||||
/**
|
||||
* 演示/开发兜底:配置后不真发短信,验证码固定为该值,把短信通道从演示关键路径摘掉。
|
||||
* prod profile 仅在 aihr.sms.demo-fixed-code-enabled=true 时临时放行。
|
||||
* prod profile 代码级禁用固定验证码,不接受配置开关绕过。
|
||||
*/
|
||||
@Value("${aihr.sms.dev-fixed-code:}")
|
||||
private String smsDevFixedCode;
|
||||
|
||||
@Value("${aihr.sms.demo-fixed-code-enabled:false}")
|
||||
private boolean smsDemoFixedCodeEnabled;
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
/**
|
||||
@@ -84,7 +81,7 @@ public class CaptchaController {
|
||||
@Pattern(regexp = RegexConstants.MOBILE, message = "{user.mobile.phone.number.not.valid}") String phonenumber) {
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + phonenumber;
|
||||
boolean fixedCodeEnabled = StringUtils.isNotBlank(smsDevFixedCode)
|
||||
&& (!environment.acceptsProfiles(Profiles.of("prod")) || smsDemoFixedCodeEnabled);
|
||||
&& !environment.acceptsProfiles(Profiles.of("prod"));
|
||||
if (fixedCodeEnabled) {
|
||||
log.warn("aihr.sms.dev-fixed-code 已启用,短信验证码走固定码,未真实发送短信");
|
||||
RedisUtils.setCacheObject(key, smsDevFixedCode, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
|
||||
Reference in New Issue
Block a user