| | |
| | | private RedisService redisService; |
| | | |
| | | private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT; |
| | | |
| | | private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME; |
| | | |
| | | @Autowired |
| | |
| | | return CacheConstants.PWD_ERR_CNT_KEY + username; |
| | | } |
| | | |
| | | public void validate(SysUser user, String password, HttpServletRequest request) |
| | | { |
| | | public void validate(SysUser user, String password, HttpServletRequest request) { |
| | | String username = user.getUserName(); |
| | | |
| | | Integer retryCount = redisService.getCacheObject(getCacheKey(username)); |
| | |
| | | throw new ServiceException(errMsg); |
| | | } |
| | | |
| | | // if (!matches(user, password)) |
| | | // { |
| | | // retryCount = retryCount + 1; |
| | | // recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, String.format("密码输入错误%s次", retryCount)); |
| | | // redisService.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES); |
| | | // throw new ServiceException("密码错误"); |
| | | // } |
| | | else |
| | | { |
| | | if (!matches(user,password)){ |
| | | retryCount = retryCount + 1; |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, String.format("密码输入错误%s次", retryCount)); |
| | | redisService.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES); |
| | | throw new ServiceException("密码错误"); |
| | | } else { |
| | | clearLoginRecordCache(username); |
| | | } |
| | | } |