From 2d37b166a2533178f81af156a02fe3409fddc9c7 Mon Sep 17 00:00:00 2001 From: JEECG <445654970@qq.com> Date: Tue, 18 Jun 2024 16:18:35 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/JeecgBootExceptionHandler.java | 2 +- .../system/controller/CommonController.java | 2 +- .../system/controller/SysDictController.java | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java index 17fa2f522..7f2e45865 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java @@ -104,7 +104,7 @@ public class JeecgBootExceptionHandler { @ExceptionHandler({UnauthorizedException.class, AuthorizationException.class}) public Result handleAuthorizationException(AuthorizationException e){ log.error(e.getMessage(), e); - return Result.noauth("没有权限,请管理员授权后,退出重新登录!"); + return Result.noauth("没有权限,请管理员授权后,刷新用户缓存或退出重新登录!"); } @ExceptionHandler(Exception.class) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java index bf3936d05..81bc201eb 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/CommonController.java @@ -51,7 +51,7 @@ public class CommonController { */ @GetMapping("/403") public Result noauth() { - return Result.error("没有权限,请管理员授权后,退出重新登录!"); + return Result.error("没有权限,请管理员授权后,刷新用户缓存或退出重新登录!"); } /** diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java index 0d1cf40b9..58e4b12e8 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysDictController.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.config.TenantContext; import org.jeecg.common.constant.CacheConstant; @@ -18,8 +19,12 @@ import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.vo.DictModel; import org.jeecg.common.system.vo.DictQuery; import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.common.util.*; +import org.jeecg.common.util.ImportExcelUtil; +import org.jeecg.common.util.RedisUtil; +import org.jeecg.common.util.TokenUtils; +import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.mybatis.MybatisPlusSaasConfig; +import org.jeecg.config.shiro.ShiroRealm; import org.jeecg.modules.system.entity.SysDict; import org.jeecg.modules.system.entity.SysDictItem; import org.jeecg.modules.system.model.SysDictTree; @@ -69,6 +74,8 @@ public class SysDictController { public RedisTemplate redisTemplate; @Autowired private RedisUtil redisUtil; + @Autowired + private ShiroRealm shiroRealm; @RequestMapping(value = "/list", method = RequestMethod.GET) public Result> queryPageList(SysDict sysDict,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @@ -482,6 +489,14 @@ public class SysDictController { redisUtil.removeAll("jmreport:cache:dict"); redisUtil.removeAll("jmreport:cache:dictTable"); //update-end-author:liusq date:20230404 for: [issue/4358]springCache中的清除缓存的操作使用了“keys” + + //update-begin---author:scott ---date:2024-06-18 for:【TV360X-1320】分配权限必须退出重新登录才生效,造成很多用户困扰--- + // 清除当前用户的授权缓存信息 + Subject currentUser = SecurityUtils.getSubject(); + if (currentUser.isAuthenticated()) { + shiroRealm.clearCache(currentUser.getPrincipals()); + } + //update-end---author:scott ---date::2024-06-18 for:【TV360X-1320】分配权限必须退出重新登录才生效,造成很多用户困扰--- return result; }