update 修改登陆失败提示语为账号,增加自定义配置密码错误重置时间
This commit is contained in:
+6
-3
@@ -60,6 +60,9 @@ public class CompanyLoginController {
|
|||||||
*/
|
*/
|
||||||
public static final int RETRY_LOGIN_MAX_COUNT = 5;
|
public static final int RETRY_LOGIN_MAX_COUNT = 5;
|
||||||
|
|
||||||
|
@Value("${passwordResetTime}")
|
||||||
|
private int passwordResetTime;
|
||||||
|
|
||||||
@ApiOperation("登录接口")
|
@ApiOperation("登录接口")
|
||||||
@PostMapping(value = "/login")
|
@PostMapping(value = "/login")
|
||||||
public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) {
|
public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) {
|
||||||
@@ -116,7 +119,7 @@ public class CompanyLoginController {
|
|||||||
retryCount = (int) redisUtil.get(RETRY_LOGIN_PREFIX + phone);
|
retryCount = (int) redisUtil.get(RETRY_LOGIN_PREFIX + phone);
|
||||||
}
|
}
|
||||||
if (retryCount >= RETRY_LOGIN_MAX_COUNT) {
|
if (retryCount >= RETRY_LOGIN_MAX_COUNT) {
|
||||||
result.error500("密码错误次数过多,请稍后重试");
|
result.error500("密码错误次数过多,密码错误次数过多,请"+passwordResetTime+"分钟后重试");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//2. 校验用户名或密码是否正确
|
//2. 校验用户名或密码是否正确
|
||||||
@@ -126,11 +129,11 @@ public class CompanyLoginController {
|
|||||||
// 重试登录次数加一
|
// 重试登录次数加一
|
||||||
retryCount++;
|
retryCount++;
|
||||||
if (retryCount == 1) {
|
if (retryCount == 1) {
|
||||||
redisUtil.set(RETRY_LOGIN_PREFIX + phone, retryCount, 60 * 30);
|
redisUtil.set(RETRY_LOGIN_PREFIX + phone, retryCount, 60 * passwordResetTime);
|
||||||
} else {
|
} else {
|
||||||
redisUtil.set(RETRY_LOGIN_PREFIX + phone, retryCount, redisUtil.getExpire(RETRY_LOGIN_PREFIX + phone));
|
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);
|
result.error500(msg);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -76,6 +76,8 @@ public class LoginController {
|
|||||||
|
|
||||||
@Value("${defaultPassword}")
|
@Value("${defaultPassword}")
|
||||||
private String defaultPassword;
|
private String defaultPassword;
|
||||||
|
@Value("${passwordResetTime}")
|
||||||
|
private int passwordResetTime;
|
||||||
|
|
||||||
@ApiOperation("登录接口")
|
@ApiOperation("登录接口")
|
||||||
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
||||||
@@ -129,7 +131,7 @@ public class LoginController {
|
|||||||
retryCount = (int) redisUtil.get(RETRY_LOGIN_PREFIX + username);
|
retryCount = (int) redisUtil.get(RETRY_LOGIN_PREFIX + username);
|
||||||
}
|
}
|
||||||
if (retryCount >= RETRY_LOGIN_MAX_COUNT) {
|
if (retryCount >= RETRY_LOGIN_MAX_COUNT) {
|
||||||
result.error500("密码错误次数过多,请稍后重试");
|
result.error500("密码错误次数过多,请"+passwordResetTime+"分钟后重试");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//2. 校验用户名或密码是否正确
|
//2. 校验用户名或密码是否正确
|
||||||
@@ -139,11 +141,11 @@ public class LoginController {
|
|||||||
// 重试登录次数加一
|
// 重试登录次数加一
|
||||||
retryCount++;
|
retryCount++;
|
||||||
if (retryCount == 1) {
|
if (retryCount == 1) {
|
||||||
redisUtil.set(RETRY_LOGIN_PREFIX + username, retryCount, 60 * 30);
|
redisUtil.set(RETRY_LOGIN_PREFIX + username, retryCount, 60 * passwordResetTime);
|
||||||
} else {
|
} else {
|
||||||
redisUtil.set(RETRY_LOGIN_PREFIX + username, retryCount, redisUtil.getExpire(RETRY_LOGIN_PREFIX + username));
|
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);
|
result.error500(msg);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -367,7 +367,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
Result<?> result = new Result<Object>();
|
Result<?> result = new Result<Object>();
|
||||||
//情况1:根据用户信息查询,该用户不存在
|
//情况1:根据用户信息查询,该用户不存在
|
||||||
if (sysUser == null) {
|
if (sysUser == null) {
|
||||||
result.error500("登录失败,用户名或密码错误!");
|
result.error500("登录失败,账号或密码错误!");
|
||||||
baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null);
|
baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,7 +301,10 @@ justauth:
|
|||||||
type: default
|
type: default
|
||||||
prefix: 'demo::'
|
prefix: 'demo::'
|
||||||
timeout: 1h
|
timeout: 1h
|
||||||
|
#默认密码
|
||||||
defaultPassword: HZWLsoft.com123
|
defaultPassword: HZWLsoft.com123
|
||||||
|
#密码错误次数重置时间
|
||||||
|
passwordResetTime: 15
|
||||||
#华为云发送短信
|
#华为云发送短信
|
||||||
huaWeiSms:
|
huaWeiSms:
|
||||||
#APP接入地址+接口访问URI
|
#APP接入地址+接口访问URI
|
||||||
@@ -320,4 +323,4 @@ standards:
|
|||||||
#消息模板替换,系统url,小程序名称
|
#消息模板替换,系统url,小程序名称
|
||||||
message:
|
message:
|
||||||
systemUrl: https://www.baidu.com/
|
systemUrl: https://www.baidu.com/
|
||||||
wxName: '小程序名称'
|
wxName: '小程序名称'
|
||||||
|
|||||||
Reference in New Issue
Block a user