From dbf071c2ea1dad8791618012084956711c63e2ce Mon Sep 17 00:00:00 2001 From: seewe <3267948089@qq.com> Date: Sun, 30 Aug 2026 18:07:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(auth):=20=E5=9B=BE=E7=89=87=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E7=B1=BB=E5=9E=8B=E6=94=AF=E6=8C=81=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=AE=A1=E7=90=86=E5=8A=A8=E6=80=81=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=20/=20Make=20image=20captcha=20type=20configurable=20via=20sys?= =?UTF-8?q?=5Fconfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 生成验证码时优先读取参数 sys.account.captchaType(math/char),未配置时回退 yml security.captcha.type - 参数经 RemoteConfigService 读取,参数管理保存后即时生效 --- .../org/dromara/auth/controller/CaptchaController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ruoyi-auth/src/main/java/org/dromara/auth/controller/CaptchaController.java b/ruoyi-auth/src/main/java/org/dromara/auth/controller/CaptchaController.java index 7676a6cde..98b62904d 100644 --- a/ruoyi-auth/src/main/java/org/dromara/auth/controller/CaptchaController.java +++ b/ruoyi-auth/src/main/java/org/dromara/auth/controller/CaptchaController.java @@ -6,6 +6,7 @@ import cn.hutool.captcha.generator.RandomGenerator; import cn.hutool.core.util.IdUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.dubbo.config.annotation.DubboReference; import org.dromara.auth.config.WaveAndCircleCaptcha; import org.dromara.auth.domain.vo.CaptchaVo; import org.dromara.auth.properties.CaptchaProperties; @@ -17,6 +18,7 @@ import org.dromara.common.core.utils.StringUtils; import org.dromara.common.redis.annotation.RateLimiter; import org.dromara.common.redis.enums.LimitType; import org.dromara.common.redis.utils.RedisUtils; +import org.dromara.system.api.RemoteConfigService; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; @@ -40,6 +42,9 @@ public class CaptchaController { private final CaptchaProperties captchaProperties; + @DubboReference + private final RemoteConfigService remoteConfigService; + /** * 生成验证码 */ @@ -64,7 +69,9 @@ public class CaptchaController { String uuid = IdUtil.simpleUUID(); String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + uuid; // 生成验证码 - String captchaType = captchaProperties.getType(); + // 验证码类型:优先取参数管理中的 sys.account.captchaType(math/char),未配置时回退 yml 配置 + String captchaType = StringUtils.blankToDefault( + remoteConfigService.getConfigValue("sys.account.captchaType"), captchaProperties.getType()); CodeGenerator codeGenerator; if ("math".equals(captchaType)) { codeGenerator = new MathGenerator(captchaProperties.getNumberLength(), false);