[ISSUE #6204] Get data from database if user or role info not found in cache. (#6206)

This commit is contained in:
MajorHe1 2021-06-30 15:11:18 +08:00 committed by GitHub
parent aaacc0bb0e
commit f4cf28afba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -158,7 +158,7 @@ public class NacosRoleServiceImpl {
public List<RoleInfo> getRoles(String username) {
List<RoleInfo> roleInfoList = roleInfoMap.get(username);
if (!authConfigs.isCachingEnabled()) {
if (!authConfigs.isCachingEnabled() || roleInfoList == null) {
Page<RoleInfo> roleInfoPage = getRolesFromDatabase(username, DEFAULT_PAGE_NO, Integer.MAX_VALUE);
if (roleInfoPage != null) {
roleInfoList = roleInfoPage.getPageItems();
@ -177,7 +177,7 @@ public class NacosRoleServiceImpl {
public List<PermissionInfo> getPermissions(String role) {
List<PermissionInfo> permissionInfoList = permissionInfoMap.get(role);
if (!authConfigs.isCachingEnabled()) {
if (!authConfigs.isCachingEnabled() || permissionInfoList == null) {
Page<PermissionInfo> permissionInfoPage = getPermissionsFromDatabase(role, DEFAULT_PAGE_NO, Integer.MAX_VALUE);
if (permissionInfoPage != null) {
permissionInfoList = permissionInfoPage.getPageItems();

View File

@ -91,7 +91,7 @@ public class NacosUserDetailsServiceImpl implements UserDetailsService {
public User getUser(String username) {
User user = userMap.get(username);
if (!authConfigs.isCachingEnabled()) {
if (!authConfigs.isCachingEnabled() || user == null) {
user = getUserFromDatabase(username);
}
return user;