mirror of https://gitee.com/stylefeng/roses
【7.0.4】【c】注册和发送邮箱验证码加上安全校验
parent
fe3e180ed0
commit
e573286f0a
|
@ -98,6 +98,16 @@ public class CustomerRequest extends BaseRequest {
|
||||||
@ChineseDescription("用户状态:1-启用,2-禁用")
|
@ChineseDescription("用户状态:1-启用,2-禁用")
|
||||||
private Integer statusFlag;
|
private Integer statusFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用在图形验证码或者拖拽验证码
|
||||||
|
*/
|
||||||
|
private String verKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用在图形验证码或者拖拽验证码
|
||||||
|
*/
|
||||||
|
private String verCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册账号
|
* 注册账号
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -102,6 +102,10 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void reg(CustomerRequest customerRequest) {
|
public void reg(CustomerRequest customerRequest) {
|
||||||
|
|
||||||
|
// 验证拖拽验证码
|
||||||
|
this.validateDragCaptcha(customerRequest.getVerKey(), customerRequest.getVerCode());
|
||||||
|
|
||||||
synchronized (REG_LOCK) {
|
synchronized (REG_LOCK) {
|
||||||
// 校验邮箱和账号是否重复
|
// 校验邮箱和账号是否重复
|
||||||
validateRepeat(customerRequest);
|
validateRepeat(customerRequest);
|
||||||
|
@ -143,17 +147,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||||
loginRequest.setRememberMe(true);
|
loginRequest.setRememberMe(true);
|
||||||
|
|
||||||
// 验证拖拽验证码
|
// 验证拖拽验证码
|
||||||
if (SecurityConfigExpander.getDragCaptchaOpen()) {
|
this.validateDragCaptcha(loginRequest.getVerKey(), loginRequest.getVerCode());
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
LambdaQueryWrapper<Customer> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Customer> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
@ -217,6 +211,9 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void sendResetPwdEmail(CustomerRequest customerRequest) {
|
public void sendResetPwdEmail(CustomerRequest customerRequest) {
|
||||||
|
|
||||||
|
// 验证拖拽验证码
|
||||||
|
this.validateDragCaptcha(customerRequest.getVerKey(), customerRequest.getVerCode());
|
||||||
|
|
||||||
// 验证邮箱是否存在
|
// 验证邮箱是否存在
|
||||||
LambdaQueryWrapper<Customer> customerLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<Customer> customerLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
customerLambdaQueryWrapper.eq(Customer::getEmail, customerRequest.getEmail());
|
customerLambdaQueryWrapper.eq(Customer::getEmail, customerRequest.getEmail());
|
||||||
|
@ -446,5 +443,22 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证拖拽验证码是否正确
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @date 2021/7/6 15:07
|
||||||
|
*/
|
||||||
|
private void validateDragCaptcha(String verKey, String verCode) {
|
||||||
|
if (SecurityConfigExpander.getDragCaptchaOpen()) {
|
||||||
|
if (StrUtil.isEmpty(verKey) || StrUtil.isEmpty(verCode)) {
|
||||||
|
throw new AuthException(ValidatorExceptionEnum.CAPTCHA_EMPTY);
|
||||||
|
}
|
||||||
|
if (!dragCaptchaApi.validateCaptcha(verKey, Convert.toInt(verCode))) {
|
||||||
|
throw new AuthException(ValidatorExceptionEnum.DRAG_CAPTCHA_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue