update
This commit is contained in:
parent
373d9f2316
commit
02513188bf
|
@ -76,7 +76,8 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
|
|||
String captchaCache = (String) redisUtils.getMapCache(RedissonConstant.CAPTCHA_CODE, captchaId);
|
||||
if (!captcha.equalsIgnoreCase(captchaCache)) {
|
||||
//获取IP失败次数
|
||||
Integer failCount = (Integer) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
String cache = (String) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
Integer failCount = ObjectUtil.isNull(cache)? 0 : Integer.valueOf(cache) ;
|
||||
if (ObjectUtil.isNull(failCount)) {
|
||||
failCount = 1;
|
||||
} else {
|
||||
|
@ -101,7 +102,8 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
|
|||
User loginUser = getOne(new QueryWrapper<User>().lambda().eq(User::getLoginName, userName));
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
//获取IP失败次数
|
||||
Integer failCount = (Integer) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
String cache = (String) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
Integer failCount = ObjectUtil.isNull(cache)? 0 : Integer.valueOf(cache) ;
|
||||
if (ObjectUtil.isNull(failCount)) {
|
||||
failCount = 1;
|
||||
} else {
|
||||
|
@ -118,7 +120,8 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
|
|||
//与数据库的密码进行匹配
|
||||
if (!loginPassword.equals(loginUser.getPassword())) {
|
||||
//获取IP失败次数
|
||||
Integer failCount = (Integer) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
String cache = (String) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
Integer failCount = ObjectUtil.isNull(cache)? 0 : Integer.valueOf(cache) ;
|
||||
if (ObjectUtil.isNull(failCount)) {
|
||||
failCount = 1;
|
||||
} else {
|
||||
|
@ -133,7 +136,8 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
|
|||
//判断账号是否停用
|
||||
if (!loginUser.getStatus()) {
|
||||
//获取IP失败次数
|
||||
Integer failCount = (Integer) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
String cache = (String) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
Integer failCount = ObjectUtil.isNull(cache)? 0 : Integer.valueOf(cache) ;
|
||||
if (ObjectUtil.isNull(failCount)) {
|
||||
failCount = 1;
|
||||
} else {
|
||||
|
@ -149,7 +153,8 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
|
|||
//判断账号角色
|
||||
if (StrUtil.isBlank(loginUser.getRoles())) {
|
||||
//获取IP失败次数
|
||||
Integer failCount = (Integer) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
String cache = (String) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
Integer failCount = ObjectUtil.isNull(cache)? 0 : Integer.valueOf(cache) ;
|
||||
if (ObjectUtil.isNull(failCount)) {
|
||||
failCount = 1;
|
||||
} else {
|
||||
|
@ -164,7 +169,8 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
|
|||
|
||||
List<Role> roleList = userService.roleListByUser(loginUser.getId());
|
||||
if (CollUtil.isEmpty(roleList)) { //获取IP失败次数
|
||||
Integer failCount = (Integer) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
String cache = (String) redisUtils.getMapCache(RedissonConstant.LOGIN_FAIL_COUNT, ip);
|
||||
Integer failCount = ObjectUtil.isNull(cache)? 0 : Integer.valueOf(cache) ;
|
||||
if (ObjectUtil.isNull(failCount)) {
|
||||
failCount = 1;
|
||||
} else {
|
||||
|
@ -294,8 +300,9 @@ public class AuthServiceImpl extends BaseService<UserMapper, User> implements IA
|
|||
public AjaxResult captcha() {
|
||||
//获取请求IP
|
||||
String ip = HttpServletUtil.getRemoteAddress();
|
||||
Integer count = (Integer) redisUtils.getMapCache(RedissonConstant.CAPTCHA_CODE_COUNT, ip);
|
||||
if (count != null && count > 5) {
|
||||
String cache = (String) redisUtils.getMapCache(RedissonConstant.CAPTCHA_CODE_COUNT, ip);
|
||||
Integer count = ObjectUtil.isNull(cache)? 0 : Integer.valueOf(cache);
|
||||
if (count != null && count > 60) {
|
||||
redisUtils.putMapCache(RedissonConstant.CAPTCHA_CODE_COUNT, ip, count + 1, 1, TimeUnit.MINUTES);
|
||||
return AjaxResult.fail("验证码获取频繁,请稍后再试");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue