From 9941e0b8944a75abb2531fcc2ccb0394881c6f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9A=86=E9=9D=9E?= <53246310+jie-fei30@users.noreply.github.com> Date: Fri, 28 Aug 2020 16:13:42 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug:=20=E4=BF=AE=E5=A4=8D=E7=AE=97?= =?UTF-8?q?=E6=95=B0=E5=9E=8B=E9=AA=8C=E8=AF=81=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=B5=AE=E7=82=B9=E5=9E=8B=E7=BB=93=E6=9E=9C=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=89=8D=E7=AB=AF=E8=BE=93=E5=85=A5=E6=95=B4=E5=BD=A2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8C=B9=E9=85=8D=E9=94=99=E8=AF=AF=20(#464)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix:fixed the capthcha generate 0.0 * fix:fixed all float result from captcha.text() in /auth/code --- .../modules/security/rest/AuthorizationController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java index afed088a..575880cb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java @@ -27,6 +27,7 @@ import me.zhengjie.annotation.rest.AnonymousGetMapping; import me.zhengjie.annotation.rest.AnonymousPostMapping; import me.zhengjie.config.RsaProperties; import me.zhengjie.exception.BadRequestException; +import me.zhengjie.modules.security.config.bean.LoginCodeEnum; import me.zhengjie.modules.security.config.bean.LoginProperties; import me.zhengjie.modules.security.config.bean.SecurityProperties; import me.zhengjie.modules.security.security.TokenProvider; @@ -119,8 +120,13 @@ public class AuthorizationController { // 获取运算的结果 Captcha captcha = loginProperties.getCaptcha(); String uuid = properties.getCodeKey() + IdUtil.simpleUUID(); + //当验证码类型为 arithmetic时且长度 >= 2 时,captcha.text()的结果有几率为浮点型 + String captchaValue = captcha.text(); + if (captcha.getCharType() - 1 == LoginCodeEnum.arithmetic.ordinal() && captchaValue.contains(".")) { + captchaValue = captchaValue.split("\\.")[0]; + } // 保存 - redisUtils.set(uuid, captcha.text(), loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES); + redisUtils.set(uuid, captchaValue, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES); // 验证码信息 Map imgResult = new HashMap(2) {{ put("img", captcha.toBase64());