Skip to main content

Users & Permissions 插件的 register.allowedFields 配置选项默认为 []

¥The Users & Permissions plugin's register.allowedFields configuration option defaults to []

在 Strapi 5 中,用户和权限插件的 register.allowedFields 配置选项默认为 []

¥In Strapi 5, the Users & Permissions plugin's register.allowedFields configuration option defaults to [].

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 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.

 Is this breaking change affecting plugins?No
 Is this breaking change automatically handled by a codemod?Yes
(see use-uid-for-config-namespace)

重大更改描述

¥Breaking change description

在 Strapi v4 中

¥In Strapi v4

默认情况下,注册表单将接受添加到用户内容类型的任何新字段,并且 Strapi 会在启动时警告每个字段。

¥Any new fields added to the User content type would be accepted by the registration form by default, and Strapi would warn about each field on startup.

用户可以选择将 config/plugins.js 文件中的 users-permissions.register.allowedFields 设置为他们想要在注册端点上接受的字段数组。例如,[’picture’] 在注册时接受图片属性。或者如果他们不想接受任何其他内容,则使用空数组 []

¥The users have the option to set users-permissions.register.allowedFields in the config/plugins.js file to an array of the fields they wanted to accept on their registration endpoint. For example, [’picture’] to accept a picture attribute on registration. Or an empty array [] if they do not want to accept anything else.

但是,如果用户未设置任何值,即当 allowedFields 未定义时,则所有用户字段都将被接受。

¥However, if users did not set any value, that is, when allowedFields is undefined, all user fields are accepted.

在 Strapi 5 中

¥In Strapi 5

未定义的 allowedFields 被视为空数组,默认情况下不接受任何字段。用户必须明确选择在注册时允许额外的字段。

¥An undefined allowedFields is treated as an empty array, and no fields are accepted by default. Users must explicitly choose to allow extra fields on registration.

迁移

¥Migration

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

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

手动程序

¥Manual procedure

codemod 应该处理此迁移。如果没有,请参阅有关如何使用 为用户和权限插件注册允许的字段 的文档。

¥A codemod should handle this migration. If not, please refer to the documentation on how to register allowed fields for the Users & Permissions plugin.