User-Permission problem with v5

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

In Strapi v4.25.11, you could easily add custom fields (like firstname and lastname) to the default User collection using the admin panel, and you could create new users via the /auth/local/register endpoint without issues. However, after updating Strapi, trying to register users with these new fields now returns a 400 error: “Invalid parameters: firstname, lastname.”

In short , this endpoint:

POST http://localhost:1337/api/auth/local/register
Content-Type: application/json

{
    "username": "user",
    "email": "user@gmail.com",
    "password": "123456",
    "firstname": "Sem"
}

v4.25.11 (node v20.13.1) → Works
v5.0.0 (node v20.13.1) → "error": { "status": 400, "name": "ValidationError", "message": "Invalid parameters: firstname"

Could you please help to figure out what might be the problem. Thank you!

You need to add custom fields in config/plugin.js

module.exports = ({env}) => ({
  "users-permissions": {
    config: {
      register: {
        allowedFields: [ this fields]