mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 02:46:50 +08:00
增加登录限制
This commit is contained in:
@@ -112,7 +112,7 @@ public class SysLoginApi extends ApiBaseController {
|
||||
// 从redis缓存中获取5分钟内登陆错误的次数
|
||||
String loginErrorNum = redisTemplate.opsForValue().get(CacheName.NAME_USER_LOGIN_ERROR_NUM+account);
|
||||
Integer loginErrorCount = 0;
|
||||
if(loginErrorNum != null || !loginErrorNum.equals("")){
|
||||
if(loginErrorNum != null){
|
||||
loginErrorCount = Integer.parseInt(loginErrorNum);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class SysLoginApi extends ApiBaseController {
|
||||
}else{
|
||||
loginErrorCount = loginErrorCount + 1;
|
||||
redisTemplate.opsForValue().set(CacheName.NAME_USER_LOGIN_ERROR_NUM+account, loginErrorCount+"", 5, TimeUnit.MINUTES);
|
||||
return error("用户名或密码错误,您还有"+(5-loginErrorCount)+"次登录机会");
|
||||
return error("用户名或密码错误,您还有"+(6-loginErrorCount)+"次登录机会");
|
||||
}
|
||||
// return error("用户名或密码错误");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user