# 管理员面板的 RBAC 系统已更新

> Source: https://strapi.nodejs.cn/cms/migration/v4-to-v5/breaking-changes/admin-panel-rbac-store-updated

🌐 The admin panel RBAC system has been updated

Strapi 5 移除了 `content-manager_rbacManager` redux 存储部分，并改为使用带有更新 `useRBAC` 钩子的常规权限系统。

🌐 Strapi 5 removes the `content-manager_rbacManager` redux store section and uses the regular permissions system with an updated `useRBAC` hook instead.

在 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.

此页面是[重大更改数据库](/cms/migration/v4-to-v5/breaking-changes)的一部分，提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the [breaking changes database](/cms/migration/v4-to-v5/breaking-changes) and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

- Is this breaking change affecting plugins? Yes
- Is this breaking change automatically handled by a codemod? No

## 重大变更描述 {#breaking-change-description}

🌐 Breaking change description

**在 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:

```tsx
const cmPermissions useSelector(state => state['content-manager_rbacManager'])
```

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

const canMain = allowedActions.canMain
```

**在 Strapi 5 中**

`content-manager_rbacManager` 已被移除，改为使用常规权限系统，这意味着 `useRBAC` 钩子的使用方式有所不同，如以下通用示例所示：

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

const canMain = allowedActions.canMain
```

## 迁移 {#migration}

🌐 Migration

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

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

### 注意 {#notes}

🌐 Notes

* 新的 RBAC API 可用，用户可以利用中间件系统与调用进行交互（见 [contributors documentation](https://contributor.strapi.io/exports/classes/StrapiApp#addrbacmiddleware)）。
* 更多信息可以在贡献者文档中的 [Fetching permissions](https://contributor.strapi.io/docs/core/admin/permissions/frontend/fetching-permissions) 和 [Authentication](https://contributor.strapi.io/docs/core/admin/features/authentication) 部分找到。

### 手动迁移 {#manual-migration}

🌐 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.
