|
@@ -3,7 +3,6 @@ package com.backendsys.modules.system.service.impl;
|
|
import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.date.DateUnit;
|
|
import cn.hutool.core.date.DateUnit;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
-import cn.hutool.core.util.NumberUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.backendsys.exception.CustException;
|
|
import com.backendsys.exception.CustException;
|
|
import com.backendsys.modules.common.config.redis.utils.RedisUtil;
|
|
import com.backendsys.modules.common.config.redis.utils.RedisUtil;
|
|
@@ -47,7 +46,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
@Autowired
|
|
@Autowired
|
|
private HttpRequestUtil httpRequestUtil;
|
|
private HttpRequestUtil httpRequestUtil;
|
|
@Autowired
|
|
@Autowired
|
|
- private CountUtilV2 countUtilV2;
|
|
|
|
|
|
+ private LockStatusUtil lockStatusUtil;
|
|
@Autowired
|
|
@Autowired
|
|
private CaptchaUtil captchaUtil;
|
|
private CaptchaUtil captchaUtil;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -70,10 +69,8 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
private String SMS_DEBUG;
|
|
private String SMS_DEBUG;
|
|
@Value("${CAPTCHA_DURATION}")
|
|
@Value("${CAPTCHA_DURATION}")
|
|
private Integer CAPTCHA_DURATION;
|
|
private Integer CAPTCHA_DURATION;
|
|
-
|
|
|
|
@Value("${REDIS_LOGIN_TOKEN_PREFIX}")
|
|
@Value("${REDIS_LOGIN_TOKEN_PREFIX}")
|
|
private String REDIS_LOGIN_TOKEN_PREFIX;
|
|
private String REDIS_LOGIN_TOKEN_PREFIX;
|
|
-
|
|
|
|
@Value("${spring.application.name}")
|
|
@Value("${spring.application.name}")
|
|
private String APPLICATION_NAME;
|
|
private String APPLICATION_NAME;
|
|
private String redisKeyOfLogin = APPLICATION_NAME + "-sms-login";
|
|
private String redisKeyOfLogin = APPLICATION_NAME + "-sms-login";
|
|
@@ -121,7 +118,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
// 删除图形验证码
|
|
// 删除图形验证码
|
|
redisUtil.delete(httpRequestUtil.getKaptchaKey());
|
|
redisUtil.delete(httpRequestUtil.getKaptchaKey());
|
|
// 添加登录错误的冻结标记
|
|
// 添加登录错误的冻结标记
|
|
- if (isIntercept) countUtilV2.setErrorCount(redisKeyOfLoginFail, username);
|
|
|
|
|
|
+ if (isIntercept) lockStatusUtil.setLockStatus(redisKeyOfLoginFail, username);
|
|
throw new CustException(errMsg, ResultEnum.INVALID_CREDENTIALS.getCode());
|
|
throw new CustException(errMsg, ResultEnum.INVALID_CREDENTIALS.getCode());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -198,7 +195,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
String captcha = sysAuth.getCaptcha();
|
|
String captcha = sysAuth.getCaptcha();
|
|
|
|
|
|
// 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
|
|
// 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
|
|
- countUtilV2.checkErrorStatus(redisKeyOfLoginFail, username);
|
|
|
|
|
|
+ lockStatusUtil.checkLockStatus(redisKeyOfLoginFail, username);
|
|
|
|
|
|
// 判断图形验证码是否正确
|
|
// 判断图形验证码是否正确
|
|
if (!captchaUtil.isCaptchaValid(captcha, httpRequestUtil.getKaptchaKey())) {
|
|
if (!captchaUtil.isCaptchaValid(captcha, httpRequestUtil.getKaptchaKey())) {
|
|
@@ -238,7 +235,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
Integer phoneValidCode = sysAuthPhone.getPhone_valid_code();
|
|
Integer phoneValidCode = sysAuthPhone.getPhone_valid_code();
|
|
|
|
|
|
// 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
|
|
// 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
|
|
- countUtilV2.checkErrorStatus(redisKeyOfLoginFail, phone);
|
|
|
|
|
|
+ lockStatusUtil.checkLockStatus(redisKeyOfLoginFail, phone);
|
|
|
|
|
|
// 判断短信验证码是否正确
|
|
// 判断短信验证码是否正确
|
|
String redisKey = redisKeyOfLogin + "-" + phone;
|
|
String redisKey = redisKeyOfLogin + "-" + phone;
|
|
@@ -284,8 +281,8 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
Integer phoneValidCode = sysUserDTO.getPhone_valid_code();
|
|
Integer phoneValidCode = sysUserDTO.getPhone_valid_code();
|
|
|
|
|
|
// 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
|
|
// 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
|
|
- countUtilV2.checkErrorStatus(redisKeyOfRegisterFail, username);
|
|
|
|
- countUtilV2.checkErrorStatus(redisKeyOfRegisterFail, phone);
|
|
|
|
|
|
+ lockStatusUtil.checkLockStatus(redisKeyOfRegisterFail, username);
|
|
|
|
+ lockStatusUtil.checkLockStatus(redisKeyOfRegisterFail, phone);
|
|
|
|
|
|
// 判断图形验证码是否正确
|
|
// 判断图形验证码是否正确
|
|
if (!captchaUtil.isCaptchaValid(captcha, httpRequestUtil.getKaptchaKey())) {
|
|
if (!captchaUtil.isCaptchaValid(captcha, httpRequestUtil.getKaptchaKey())) {
|