fix 修复存在其他用户类型时报null异常

Signed-off-by: 这夏天依然平凡 <1822213252@qq.com>
This commit is contained in:
这夏天依然平凡 2023-10-10 03:53:33 +00:00 committed by Gitee
parent 7544ae318c
commit 3d5c7002ef
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 5 deletions

View File

@ -10,7 +10,7 @@ public interface UserConstants {
/** /**
* 平台内系统用户的唯一标志 * 平台内系统用户的唯一标志
*/ */
String SYS_USER = "SYS_USER"; String SYS_USER = "sys_user";
/** /**
* 正常状态 * 正常状态

View File

@ -454,12 +454,15 @@ public class SysRoleServiceImpl implements ISysRoleService {
return; return;
} }
LoginUser loginUser = LoginHelper.getLoginUser(token); LoginUser loginUser = LoginHelper.getLoginUser(token);
if (ObjectUtil.isNotNull(loginUser) && loginUser.getRoles().stream().anyMatch(r -> r.getRoleId().equals(roleId))) { if (ObjectUtil.isNotNull(loginUser)) {
if (loginUser.getUserType().equals(UserConstants.SYS_USER)
&& loginUser.getRoles().stream().anyMatch(r -> r.getRoleId().equals(roleId))) {
try { try {
StpUtil.logoutByTokenValue(token); StpUtil.logoutByTokenValue(token);
} catch (NotLoginException ignored) { } catch (NotLoginException ignored) {
} }
} }
}
}); });
} }
} }