【7.0.4】【captcha】更新拖拽验证码流程

pull/22/head
fengshuonan 2021-07-05 16:13:09 +08:00
parent 9ec129809b
commit a030648b15
3 changed files with 34 additions and 1 deletions

View File

@ -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());

View File

@ -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", "拖拽验证码错误");
/**
*

View File

@ -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);
}
/**
*
*