fix:fixed all float result from captcha.text() in /auth/code

pull/464/head
wangmingcan 2020-08-19 12:02:45 +08:00
parent 6a4c9bc7c2
commit f0b620dbb6
1 changed files with 3 additions and 3 deletions

View File

@ -120,10 +120,10 @@ public class AuthorizationController {
// 获取运算的结果 // 获取运算的结果
Captcha captcha = loginProperties.getCaptcha(); Captcha captcha = loginProperties.getCaptcha();
String uuid = properties.getCodeKey() + IdUtil.simpleUUID(); String uuid = properties.getCodeKey() + IdUtil.simpleUUID();
//当验证码类型为 arithmetic时运算结果为0时captcha.text()的结果为0.0 //当验证码类型为 arithmetic时且长度 >= 2 时captcha.text()的结果有几率为浮点型
String captchaValue = captcha.text(); String captchaValue = captcha.text();
if (captcha.getCharType() - 1 == LoginCodeEnum.arithmetic.ordinal() & captchaValue.equalsIgnoreCase("0.0")) { if (captcha.getCharType() - 1 == LoginCodeEnum.arithmetic.ordinal() & captchaValue.contains(".")) {
captchaValue = "0"; captchaValue = captchaValue.split("\\.")[0];
} }
// 保存 // 保存
redisUtils.set(uuid, captchaValue, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES); redisUtils.set(uuid, captchaValue, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES);