Browse Source

fix 修复 普通角色编辑使用内置管理员code越权问题

疯狂的狮子Li 1 year ago
parent
commit
8de02e285e

+ 6 - 3
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java

@@ -195,9 +195,12 @@ public class SysRoleServiceImpl implements ISysRoleService {
         if (ObjectUtil.isNotNull(role.getRoleId())) {
             SysRole sysRole = baseMapper.selectById(role.getRoleId());
             // 如果标识符不相等 判断为修改了管理员标识符
-            if (!StringUtils.equals(sysRole.getRoleKey(), role.getRoleKey())
-                && StringUtils.equals(sysRole.getRoleKey(), UserConstants.ADMIN_ROLE_KEY)) {
-                throw new ServiceException("不允许修改系统内置管理员角色标识符!");
+            if (!StringUtils.equals(sysRole.getRoleKey(), role.getRoleKey())) {
+                if (StringUtils.equals(sysRole.getRoleKey(), UserConstants.ADMIN_ROLE_KEY)) {
+                    throw new ServiceException("不允许修改系统内置管理员角色标识符!");
+                } else if (StringUtils.equals(role.getRoleKey(), UserConstants.ADMIN_ROLE_KEY)) {
+                    throw new ServiceException("不允许使用系统内置管理员角色标识符!");
+                }
             }
         }
     }