From f4cf28afbab462a1c9524a327a0c50ab899fd5a9 Mon Sep 17 00:00:00 2001 From: MajorHe1 <53824889+MajorHe1@users.noreply.github.com> Date: Wed, 30 Jun 2021 15:11:18 +0800 Subject: [PATCH] [ISSUE #6204] Get data from database if user or role info not found in cache. (#6206) --- .../console/security/nacos/roles/NacosRoleServiceImpl.java | 4 ++-- .../security/nacos/users/NacosUserDetailsServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/console/src/main/java/com/alibaba/nacos/console/security/nacos/roles/NacosRoleServiceImpl.java b/console/src/main/java/com/alibaba/nacos/console/security/nacos/roles/NacosRoleServiceImpl.java index 6fc1f6850..4f8576d69 100644 --- a/console/src/main/java/com/alibaba/nacos/console/security/nacos/roles/NacosRoleServiceImpl.java +++ b/console/src/main/java/com/alibaba/nacos/console/security/nacos/roles/NacosRoleServiceImpl.java @@ -158,7 +158,7 @@ public class NacosRoleServiceImpl { public List getRoles(String username) { List roleInfoList = roleInfoMap.get(username); - if (!authConfigs.isCachingEnabled()) { + if (!authConfigs.isCachingEnabled() || roleInfoList == null) { Page roleInfoPage = getRolesFromDatabase(username, DEFAULT_PAGE_NO, Integer.MAX_VALUE); if (roleInfoPage != null) { roleInfoList = roleInfoPage.getPageItems(); @@ -177,7 +177,7 @@ public class NacosRoleServiceImpl { public List getPermissions(String role) { List permissionInfoList = permissionInfoMap.get(role); - if (!authConfigs.isCachingEnabled()) { + if (!authConfigs.isCachingEnabled() || permissionInfoList == null) { Page permissionInfoPage = getPermissionsFromDatabase(role, DEFAULT_PAGE_NO, Integer.MAX_VALUE); if (permissionInfoPage != null) { permissionInfoList = permissionInfoPage.getPageItems(); diff --git a/console/src/main/java/com/alibaba/nacos/console/security/nacos/users/NacosUserDetailsServiceImpl.java b/console/src/main/java/com/alibaba/nacos/console/security/nacos/users/NacosUserDetailsServiceImpl.java index 3f8457d24..6ae387ad4 100644 --- a/console/src/main/java/com/alibaba/nacos/console/security/nacos/users/NacosUserDetailsServiceImpl.java +++ b/console/src/main/java/com/alibaba/nacos/console/security/nacos/users/NacosUserDetailsServiceImpl.java @@ -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;