新增登录验证码开关
This commit is contained in:
parent
d2fab3b212
commit
cc316d5843
|
@ -0,0 +1,13 @@
|
||||||
|
package net.maku.system.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统参数 枚举
|
||||||
|
*
|
||||||
|
* @author 阿沐 babamu@126.com
|
||||||
|
*/
|
||||||
|
public enum SysParamsEnum {
|
||||||
|
/**
|
||||||
|
* 登录验证码
|
||||||
|
*/
|
||||||
|
LOGIN_CAPTCHA
|
||||||
|
}
|
|
@ -7,7 +7,9 @@ import com.wf.captcha.base.Captcha;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.maku.framework.common.cache.RedisCache;
|
import net.maku.framework.common.cache.RedisCache;
|
||||||
import net.maku.framework.common.cache.RedisKeys;
|
import net.maku.framework.common.cache.RedisKeys;
|
||||||
|
import net.maku.system.enums.SysParamsEnum;
|
||||||
import net.maku.system.service.SysCaptchaService;
|
import net.maku.system.service.SysCaptchaService;
|
||||||
|
import net.maku.system.service.SysParamsService;
|
||||||
import net.maku.system.vo.SysCaptchaVO;
|
import net.maku.system.vo.SysCaptchaVO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -20,6 +22,7 @@ import org.springframework.stereotype.Service;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SysCaptchaServiceImpl implements SysCaptchaService {
|
public class SysCaptchaServiceImpl implements SysCaptchaService {
|
||||||
private final RedisCache redisCache;
|
private final RedisCache redisCache;
|
||||||
|
private final SysParamsService sysParamsService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysCaptchaVO generate() {
|
public SysCaptchaVO generate() {
|
||||||
|
@ -46,6 +49,11 @@ public class SysCaptchaServiceImpl implements SysCaptchaService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validate(String key, String code) {
|
public boolean validate(String key, String code) {
|
||||||
|
// 如果关闭了验证码,则直接效验通过
|
||||||
|
if (!isCaptchaEnabled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (StrUtil.isBlank(key) || StrUtil.isBlank(code)) {
|
if (StrUtil.isBlank(key) || StrUtil.isBlank(code)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -67,4 +75,13 @@ public class SysCaptchaServiceImpl implements SysCaptchaService {
|
||||||
|
|
||||||
return captcha;
|
return captcha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启登录验证码
|
||||||
|
*
|
||||||
|
* @return true:开启 false:关闭
|
||||||
|
*/
|
||||||
|
private boolean isCaptchaEnabled() {
|
||||||
|
return sysParamsService.getBoolean(SysParamsEnum.LOGIN_CAPTCHA.name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user