add 增加验证码开关

This commit is contained in:
朱杰
2021-05-25 11:03:24 +08:00
committed by 疯狂的狮子li
parent 3131b7ea9d
commit 5dc873209e
4 changed files with 34 additions and 19 deletions

View File

@ -52,6 +52,12 @@ public class CaptchaController {
*/
@GetMapping("/captchaImage")
public AjaxResult getCode() {
Map<String, Object> ajax = new HashMap<>();
Boolean enabled = captchaProperties.getEnabled();
ajax.put("enabled", enabled);
if (!enabled) {
return AjaxResult.success(ajax);
}
// 保存验证码信息
String uuid = IdUtil.simpleUUID();
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
@ -90,7 +96,6 @@ public class CaptchaController {
code = captcha.getCode();
}
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
Map<String,Object> ajax = new HashMap<>();
ajax.put("uuid", uuid);
ajax.put("img", captcha.getImageBase64());
return AjaxResult.success(ajax);

View File

@ -14,6 +14,8 @@ ruoyi:
addressEnabled: false
captcha:
# 验证码开关
enabled: true
# 验证码类型 math 数组计算 char 字符验证
type: math
# line 线段干扰 circle 圆圈干扰 shear 扭曲干扰