From 1a7bcc10bd4ae6abc385516a481f32c0f0e0eebc Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 21 Oct 2024 16:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9D=83=E9=99=90=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=90=8E=E5=90=8C=E6=AD=A5=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/system/SysLoginController.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index dab2bf87..e575d287 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -12,9 +12,11 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.model.LoginBody; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.framework.web.service.SysLoginService; import com.ruoyi.framework.web.service.SysPermissionService; +import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.service.ISysMenuService; /** @@ -34,6 +36,9 @@ public class SysLoginController @Autowired private SysPermissionService permissionService; + @Autowired + private TokenService tokenService; + /** * 登录方法 * @@ -59,11 +64,17 @@ public class SysLoginController @GetMapping("getInfo") public AjaxResult getInfo() { - SysUser user = SecurityUtils.getLoginUser().getUser(); + LoginUser loginUser = SecurityUtils.getLoginUser(); + SysUser user = loginUser.getUser(); // 角色集合 Set roles = permissionService.getRolePermission(user); // 权限集合 Set permissions = permissionService.getMenuPermission(user); + if (!loginUser.getPermissions().equals(permissions)) + { + loginUser.setPermissions(permissions); + tokenService.refreshToken(loginUser); + } AjaxResult ajax = AjaxResult.success(); ajax.put("user", user); ajax.put("roles", roles);