| | |
| | | |
| | | 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("用户名/密码错误"); |
| | | retryCount = (int) redisService.incrementCacheValue(getCacheKey(username), lockTime, TimeUnit.MINUTES); |
| | | redisService.expire(getCacheKey(username), lockTime, TimeUnit.MINUTES); |
| | | String errMsg = String.format("密码输入错误%s次", retryCount); |
| | | recordLogService.recordLogininfor(request, user.getUserId().intValue(), username, Constants.LOGIN_FAIL_STATUS, errMsg); |
| | | if (retryCount >= maxRetryCount) |
| | | { |
| | | throw new ServiceException(String.format("密码输入错误%s次,帐户锁定%s分钟", maxRetryCount, lockTime)); |
| | | } |
| | | throw new ServiceException("用户名或密码错误"); |
| | | } |
| | | else |
| | | { |