update 修改登陆失败提示语为账号,增加自定义配置密码错误重置时间

This commit is contained in:
lijiarao
2021-10-13 15:41:12 +08:00
parent d90bbf229f
commit 1cd953a7a2
4 changed files with 16 additions and 8 deletions
@@ -76,6 +76,8 @@ public class LoginController {
@Value("${defaultPassword}")
private String defaultPassword;
@Value("${passwordResetTime}")
private int passwordResetTime;
@ApiOperation("登录接口")
@RequestMapping(value = "/login", method = RequestMethod.POST)
@@ -129,7 +131,7 @@ public class LoginController {
retryCount = (int) redisUtil.get(RETRY_LOGIN_PREFIX + username);
}
if (retryCount >= RETRY_LOGIN_MAX_COUNT) {
result.error500("密码错误次数过多,请后重试");
result.error500("密码错误次数过多,请"+passwordResetTime+"分钟后重试");
return result;
}
//2. 校验用户名或密码是否正确
@@ -139,11 +141,11 @@ public class LoginController {
// 重试登录次数加一
retryCount++;
if (retryCount == 1) {
redisUtil.set(RETRY_LOGIN_PREFIX + username, retryCount, 60 * 30);
redisUtil.set(RETRY_LOGIN_PREFIX + username, retryCount, 60 * passwordResetTime);
} else {
redisUtil.set(RETRY_LOGIN_PREFIX + username, retryCount, redisUtil.getExpire(RETRY_LOGIN_PREFIX + username));
}
String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请后重试" : "用户名或密码错误,剩余可登录次数:" + (RETRY_LOGIN_MAX_COUNT - retryCount);
String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请"+passwordResetTime+"分钟后重试" : "账号或密码错误,剩余可登录次数:" + (RETRY_LOGIN_MAX_COUNT - retryCount);
result.error500(msg);
return result;
}
@@ -367,7 +367,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
Result<?> result = new Result<Object>();
//情况1:根据用户信息查询,该用户不存在
if (sysUser == null) {
result.error500("登录失败,用户名或密码错误!");
result.error500("登录失败,账号或密码错误!");
baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null);
return result;
}