Skip to main content

管理面板 RBAC 系统已更新

¥The admin panel RBAC system has been updated

在 Strapi 5 中,content-manager_rbacManager(Strapi 的管理面板 redux 存储的一部分)被删除,取而代之的是使用常规权限系统。此外,useRBAC 钩子已更新。

¥In Strapi 5, the content-manager_rbacManager, which is a section of Strapi's redux store for the admin panel, is removed and the regular permissions system is used instead. Additionally, the useRBAC hook is updated.

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的其他说明。

¥This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

\🔌 此重大更改是否会影响插件?\
\🤖 此重大更改是否由 codemod 自动处理?\

重大更改描述

¥Breaking change description

在 Strapi v4 中

¥In Strapi v4

权限由 redux 存储的 content-manager_rbacManager 部分处理,如以下通用示例所示:

¥Permissions are handled with the content-manager_rbacManager section of the redux store, like in the following generic example:

const cmPermissions useSelector(state => state['content-manager_rbacManager'])
const { allowedActions } = useRBAC({
main: [{ action: 'admin::something.main', subject: null }]
})



const canMain = allowedActions.canMain


在 Strapi 5 中

¥In Strapi 5

content-manager_rbacManager 被删除,取而代之的是使用常规权限系统,这意味着 useRBAC 钩子的使用方式不同,如以下通用示例所示:

¥content-manager_rbacManager is removed and the regular permissions system is used instead, which implies the useRBAC hook is used differently, as in the following generic example:

const { allowedActions } = useRBAC([
{ action: 'admin::something.main', subject: null }
])



const canMain = allowedActions.canMain


迁移

¥Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

¥This section regroups useful notes and procedures about the introduced breaking change.

注意

¥Notes

手动迁移

¥Manual migration

如果确实需要,仍在使用该函数的插件开发者应将其用法替换为真正的模板库。

¥Plugin developers that are hooking into the redux store to tweak RBAC permissions in Strapi v4 need to update their code according to the described changes.