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;
|
||||
}
|
||||
|
||||
+5
-3
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -301,7 +301,10 @@ justauth:
|
||||
type: default
|
||||
prefix: 'demo::'
|
||||
timeout: 1h
|
||||
#默认密码
|
||||
defaultPassword: HZWLsoft.com123
|
||||
#密码错误次数重置时间
|
||||
passwordResetTime: 15
|
||||
#华为云发送短信
|
||||
huaWeiSms:
|
||||
#APP接入地址+接口访问URI
|
||||
@@ -320,4 +323,4 @@ standards:
|
||||
#消息模板替换,系统url,小程序名称
|
||||
message:
|
||||
systemUrl: https://www.baidu.com/
|
||||
wxName: '小程序名称'
|
||||
wxName: '小程序名称'
|
||||
|
||||
Reference in New Issue
Block a user