【fix bug】67865
This commit is contained in:
+20
-12
@@ -131,23 +131,13 @@ public class LoginServiceImpl implements ILoginService {
|
||||
if (!syspassword.equals(userpassword)) {
|
||||
// 重试登录次数加一
|
||||
retryCount++;
|
||||
if( retryCount == 1){
|
||||
redisUtil.set(RETRY_LOGIN_PREFIX + username,retryCount,60L * 15L);
|
||||
}else {
|
||||
redisUtil.set(RETRY_LOGIN_PREFIX + username,retryCount,redisUtil.getExpire(RETRY_LOGIN_PREFIX + username));
|
||||
}
|
||||
setRedis(username, retryCount);
|
||||
String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请稍后重试":"用户名或密码错误,剩余可登录次数:"+(RETRY_LOGIN_MAX_COUNT - retryCount);
|
||||
return Results.error(msg);
|
||||
}
|
||||
//登录成功,清除错误登录次数
|
||||
redisUtil.del(RETRY_LOGIN_PREFIX + username);
|
||||
// 登录成功之后验证是否有权限
|
||||
List<SysPermission> metaList = sysPermissionService.queryByUser(username);
|
||||
if(CollectionUtils.isEmpty(metaList)){
|
||||
return Results.error("该用户无权限,请联系管理员!");
|
||||
}
|
||||
long l = metaList.stream().filter(o->Objects.equals(o.getMenuType(),0)).count();
|
||||
if(l <= 0){
|
||||
if (checkSysPermission(username)) {
|
||||
return Results.error("该用户无权限,请联系管理员!");
|
||||
}
|
||||
|
||||
@@ -165,6 +155,24 @@ public class LoginServiceImpl implements ILoginService {
|
||||
|
||||
}
|
||||
|
||||
private void setRedis(String username, int retryCount) {
|
||||
if( retryCount == 1){
|
||||
redisUtil.set(RETRY_LOGIN_PREFIX + username,retryCount,60L * 15L);
|
||||
}else {
|
||||
redisUtil.set(RETRY_LOGIN_PREFIX + username,retryCount,redisUtil.getExpire(RETRY_LOGIN_PREFIX + username));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkSysPermission(String username) {
|
||||
// 登录成功之后验证是否有权限
|
||||
List<SysPermission> metaList = sysPermissionService.queryByUser(username);
|
||||
if(CollectionUtils.isEmpty(metaList)){
|
||||
return true;
|
||||
}
|
||||
long l = metaList.stream().filter(o-> Objects.equals(o.getMenuType(),0)).count();
|
||||
return l <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Results<Object> logout(HttpServletRequest request, HttpServletResponse response) {
|
||||
//用户退出逻辑
|
||||
|
||||
Reference in New Issue
Block a user