From cff5ec5a401ff102e03b9433d23b328c000a03fd Mon Sep 17 00:00:00 2001 From: JEECG <445654970@qq.com> Date: Tue, 18 Jun 2024 16:04:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=EF=BC=9A=E5=88=86=E9=85=8D?= =?UTF-8?q?=E6=9D=83=E9=99=90=E5=BF=85=E9=A1=BB=E9=80=80=E5=87=BA=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E7=99=BB=E5=BD=95=E6=89=8D=E7=94=9F=E6=95=88=EF=BC=8C?= =?UTF-8?q?=E9=80=A0=E6=88=90=E5=BE=88=E5=A4=9A=E7=94=A8=E6=88=B7=E5=9B=B0?= =?UTF-8?q?=E6=89=B0(=E7=9B=AE=E5=89=8D=E6=94=B9=E6=B3=95=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=EF=BC=9A=E5=8F=AA=E9=92=88=E5=AF=B9=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E4=BA=BA=E7=9A=84=E6=9D=83=E9=99=90=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=94=9F=E6=95=88)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/config/shiro/ShiroRealm.java | 4 +++- .../controller/SysPermissionController.java | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java index 9314d39e7..e6bc5cdb3 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroRealm.java @@ -226,6 +226,8 @@ public class ShiroRealm extends AuthorizingRealm { @Override public void clearCache(PrincipalCollection principals) { super.clearCache(principals); + //update-begin---author:scott ---date::2024-06-18 for:【TV360X-1320】分配权限必须退出重新登录才生效,造成很多用户困扰--- + super.clearCachedAuthorizationInfo(principals); + //update-end---author:scott ---date::2024-06-18 for:【TV360X-1320】分配权限必须退出重新登录才生效,造成很多用户困扰--- } - } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java index 738afef26..1924282c9 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysPermissionController.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.subject.Subject; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.SymbolConstant; @@ -15,6 +16,7 @@ import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.Md5Util; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; +import org.jeecg.config.shiro.ShiroRealm; import org.jeecg.modules.base.service.BaseCommonService; import org.jeecg.modules.system.constant.DefIndexConst; import org.jeecg.modules.system.entity.*; @@ -65,6 +67,9 @@ public class SysPermissionController { @Autowired private ISysRoleIndexService sysRoleIndexService; + + @Autowired + private ShiroRealm shiroRealm; /** * 子菜单 @@ -597,6 +602,16 @@ public class SysPermissionController { //update-end---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------ result.success("保存成功!"); log.info("======角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒"); + + //update-begin---author:scott ---date:2024-06-18 for:【TV360X-1320】分配权限必须退出重新登录才生效,造成很多用户困扰--- + // 获取当前用户的Subject对象 + Subject currentUser = SecurityUtils.getSubject(); + // 清除当前用户的授权缓存信息 + if (currentUser.isAuthenticated()) { + shiroRealm.clearCache(currentUser.getPrincipals()); + } + //update-end---author:scott ---date::2024-06-18 for:【TV360X-1320】分配权限必须退出重新登录才生效,造成很多用户困扰--- + } catch (Exception e) { result.error500("授权失败!"); log.error(e.getMessage(), e);