mirror of https://gitee.com/stylefeng/roses
【7.0.4】【captcha】更新拖拽验证码流程
parent
9ec129809b
commit
a030648b15
|
@ -25,6 +25,7 @@
|
|||
package cn.stylefeng.roses.kernel.auth.auth;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
@ -55,6 +56,7 @@ import cn.stylefeng.roses.kernel.jwt.api.pojo.payload.DefaultJwtPayload;
|
|||
import cn.stylefeng.roses.kernel.log.api.LoginLogServiceApi;
|
||||
import cn.stylefeng.roses.kernel.message.api.expander.WebSocketConfigExpander;
|
||||
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
||||
import cn.stylefeng.roses.kernel.security.api.DragCaptchaApi;
|
||||
import cn.stylefeng.roses.kernel.security.api.ImageCaptchaApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.api.enums.UserStatusEnum;
|
||||
|
@ -104,6 +106,9 @@ public class AuthServiceImpl implements AuthServiceApi {
|
|||
@Resource
|
||||
private ImageCaptchaApi captchaApi;
|
||||
|
||||
@Resource
|
||||
private DragCaptchaApi dragCaptchaApi;
|
||||
|
||||
@Resource
|
||||
private SsoProperties ssoProperties;
|
||||
|
||||
|
@ -263,6 +268,19 @@ public class AuthServiceImpl implements AuthServiceApi {
|
|||
}
|
||||
}
|
||||
|
||||
// 2.1 验证拖拽验证码
|
||||
if (SystemConfigExpander.getDragCaptchaOpen()) {
|
||||
String verKey = loginRequest.getVerKey();
|
||||
String verXLocationValue = loginRequest.getVerCode();
|
||||
|
||||
if (StrUtil.isEmpty(verKey) || StrUtil.isEmpty(verXLocationValue)) {
|
||||
throw new AuthException(ValidatorExceptionEnum.CAPTCHA_EMPTY);
|
||||
}
|
||||
if (!dragCaptchaApi.validateCaptcha(verKey, Convert.toInt(verXLocationValue))) {
|
||||
throw new AuthException(ValidatorExceptionEnum.DRAG_CAPTCHA_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 解密密码的密文
|
||||
// String decryptPassword = passwordTransferEncryptApi.decrypt(loginRequest.getPassword());
|
||||
|
||||
|
|
|
@ -88,7 +88,12 @@ public enum ValidatorExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 数据库唯一性校验错误,sql执行错误
|
||||
*/
|
||||
UNIQUE_VALIDATE_SQL_ERROR(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + ValidatorConstants.VALIDATOR_EXCEPTION_STEP_CODE + "10", "数据库唯一性校验错误,sql执行错误,具体信息:{}");
|
||||
UNIQUE_VALIDATE_SQL_ERROR(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + ValidatorConstants.VALIDATOR_EXCEPTION_STEP_CODE + "10", "数据库唯一性校验错误,sql执行错误,具体信息:{}"),
|
||||
|
||||
/**
|
||||
* 拖拽验证码错误
|
||||
*/
|
||||
DRAG_CAPTCHA_ERROR(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + ValidatorConstants.VALIDATOR_EXCEPTION_STEP_CODE + "11", "拖拽验证码错误");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
|
|
|
@ -67,6 +67,16 @@ public class SystemConfigExpander {
|
|||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_CAPTCHA_OPEN", Boolean.class, SystemConstants.DEFAULT_CAPTCHA_OPEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拖拽验证码的开关
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/27 17:22
|
||||
*/
|
||||
public static Boolean getDragCaptchaOpen() {
|
||||
return ConfigContext.me().getSysConfigValueWithDefault("SYS_DRAG_CAPTCHA_OPEN", Boolean.class, SystemConstants.DEFAULT_CAPTCHA_OPEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统名称
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue