update 修改登陆失败提示语为账号,增加自定义配置密码错误重置时间
This commit is contained in:
+6
-3
@@ -60,6 +60,9 @@ public class CompanyLoginController {
|
||||
*/
|
||||
public static final int RETRY_LOGIN_MAX_COUNT = 5;
|
||||
|
||||
@Value("${passwordResetTime}")
|
||||
private int passwordResetTime;
|
||||
|
||||
@ApiOperation("登录接口")
|
||||
@PostMapping(value = "/login")
|
||||
public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) {
|
||||
@@ -116,7 +119,7 @@ public class CompanyLoginController {
|
||||
retryCount = (int) redisUtil.get(RETRY_LOGIN_PREFIX + phone);
|
||||
}
|
||||
if (retryCount >= RETRY_LOGIN_MAX_COUNT) {
|
||||
result.error500("密码错误次数过多,请稍后重试");
|
||||
result.error500("密码错误次数过多,密码错误次数过多,请"+passwordResetTime+"分钟后重试");
|
||||
return result;
|
||||
}
|
||||
//2. 校验用户名或密码是否正确
|
||||
@@ -126,11 +129,11 @@ public class CompanyLoginController {
|
||||
// 重试登录次数加一
|
||||
retryCount++;
|
||||
if (retryCount == 1) {
|
||||
redisUtil.set(RETRY_LOGIN_PREFIX + phone, retryCount, 60 * 30);
|
||||
redisUtil.set(RETRY_LOGIN_PREFIX + phone, retryCount, 60 * passwordResetTime);
|
||||
} else {
|
||||
redisUtil.set(RETRY_LOGIN_PREFIX + phone, retryCount, redisUtil.getExpire(RETRY_LOGIN_PREFIX + phone));
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user