用户与权限插件的 register.allowedFields 配置选项默认值为 []
🌐 The Users & Permissions plugin's register.allowedFields configuration option defaults to []
在 Strapi 5 中,Users & Permissions 插件的 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.
重大变更描述
🌐 Breaking change description
在 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 中
未定义的 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.