【代码优化】全局:userId 为空时,直接校验权限不通过

This commit is contained in:
YunaiV 2024-07-23 22:40:33 +08:00
parent 39bf9cf5b0
commit aef833fb9f

View File

@ -27,7 +27,11 @@ public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {
@Override
public boolean hasAnyPermissions(String... permissions) {
return permissionApi.hasAnyPermissions(getLoginUserId(), permissions);
Long userId = getLoginUserId();
if (userId == null) {
return false;
}
return permissionApi.hasAnyPermissions(userId, permissions);
}
@Override
@ -37,7 +41,11 @@ public class SecurityFrameworkServiceImpl implements SecurityFrameworkService {
@Override
public boolean hasAnyRoles(String... roles) {
return permissionApi.hasAnyRoles(getLoginUserId(), roles);
Long userId = getLoginUserId();
if (userId == null) {
return false;
}
return permissionApi.hasAnyRoles(userId, roles);
}
@Override