add
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
package com.qiaoba.auth.service.impl;
|
package com.qiaoba.auth.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.captcha.generator.MathGenerator;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.qiaoba.api.auth.service.AuthConfigApiService;
|
import com.qiaoba.api.auth.service.AuthConfigApiService;
|
||||||
import com.qiaoba.api.auth.constants.SecurityConstant;
|
import com.qiaoba.api.auth.constants.SecurityConstant;
|
||||||
@ -69,7 +70,7 @@ public class AuthConfigServiceImpl implements AuthConfigApiService {
|
|||||||
if (StrUtil.isBlank(realCode)) {
|
if (StrUtil.isBlank(realCode)) {
|
||||||
throw new ServiceException("验证码已经过期失效!");
|
throw new ServiceException("验证码已经过期失效!");
|
||||||
} else {
|
} else {
|
||||||
if (!code.equalsIgnoreCase(realCode)) {
|
if (!new MathGenerator().verify(realCode, code)) {
|
||||||
throw new ServiceException("验证码输入错误!");
|
throw new ServiceException("验证码输入错误!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.qiaoba.auth.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.captcha.CaptchaUtil;
|
import cn.hutool.captcha.CaptchaUtil;
|
||||||
import cn.hutool.captcha.LineCaptcha;
|
import cn.hutool.captcha.LineCaptcha;
|
||||||
|
import cn.hutool.captcha.generator.MathGenerator;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.lang.UUID;
|
import cn.hutool.core.lang.UUID;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
@ -66,7 +67,11 @@ public class SysLoginServiceImpl implements SysLoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String uuid = UUID.randomUUID().toString(true);
|
String uuid = UUID.randomUUID().toString(true);
|
||||||
LineCaptcha captcha = CaptchaUtil.createLineCaptcha(150, 50, 4, 20);
|
LineCaptcha captcha = CaptchaUtil.createLineCaptcha(150, 50, 4, 0);
|
||||||
|
// 自定义验证码内容为四则运算方式
|
||||||
|
captcha.setGenerator(new MathGenerator(1));
|
||||||
|
// 重新生成code
|
||||||
|
captcha.createCode();
|
||||||
map.put("uuid", uuid);
|
map.put("uuid", uuid);
|
||||||
map.put("img", captcha.getImageBase64());
|
map.put("img", captcha.getImageBase64());
|
||||||
redisService.set(SecurityConstant.CAPTCHA_KEY + uuid, captcha.getCode(), 120);
|
redisService.set(SecurityConstant.CAPTCHA_KEY + uuid, captcha.getCode(), 120);
|
||||||
|
@ -53,12 +53,14 @@ public class SysConfigServiceImpl implements SysConfigService {
|
|||||||
@Override
|
@Override
|
||||||
public int updateById(SysConfig sysConfig) {
|
public int updateById(SysConfig sysConfig) {
|
||||||
checkKeyIsExist(sysConfig);
|
checkKeyIsExist(sysConfig);
|
||||||
|
String configKey = sysConfig.getConfigKey();
|
||||||
// key 禁止修改
|
// key 禁止修改
|
||||||
sysConfig.setConfigKey(null);
|
sysConfig.setConfigKey(null);
|
||||||
sysConfig.setUpdateTime(new Date());
|
sysConfig.setUpdateTime(new Date());
|
||||||
sysConfig.setUpdateUser(SecurityUtil.getLoginUsername());
|
sysConfig.setUpdateUser(SecurityUtil.getLoginUsername());
|
||||||
int result = sysConfigMapper.updateById(sysConfig);
|
int result = sysConfigMapper.updateById(sysConfig);
|
||||||
if (result > BaseConstant.HANDLE_ERROR) {
|
if (result > BaseConstant.HANDLE_ERROR) {
|
||||||
|
sysConfig.setConfigKey(configKey);
|
||||||
cacheConfig(sysConfig);
|
cacheConfig(sysConfig);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Reference in New Issue
Block a user