admin管理员组

文章数量:1123092

I'm pretty new with Strapi and I'm trying to add some functionality to the registration flow. I've added nickname to my User collection type.

The schema.json looks like this:

{
      "kind": "collectionType",
      "collectionName": "up_users",
      "info": {
        "name": "user",
        "description": "",
        "singularName": "user",
        "pluralName": "users",
        "displayName": "User"
      },
      "options": {
        "draftAndPublish": false
      },
      "attributes": {
        "username": {
          "type": "string",
          "minLength": 3,
          "unique": true,
          "configurable": false,
          "required": true
        },
        "email": {
          "type": "email",
          "minLength": 6,
          "configurable": false,
          "required": true
        },
        "provider": {
          "type": "string",
          "configurable": false
        },
        "password": {
          "type": "password",
          "minLength": 6,
          "configurable": false,
          "private": true,
          "searchable": false
        },
        "resetPasswordToken": {
          "type": "string",
          "configurable": false,
          "private": true,
          "searchable": false
        },
        "confirmationToken": {
          "type": "string",
          "configurable": false,
          "private": true,
          "searchable": false
        },
        "confirmed": {
          "type": "boolean",
          "default": false,
          "configurable": false
        },
        "blocked": {
          "type": "boolean",
          "default": false,
          "configurable": false
        },
        "role": {
          "type": "relation",
          "relation": "manyToOne",
          "target": "plugin::users-permissions.role",
          "inversedBy": "users",
          "configurable": false
        },
        "nickname": {
          "type": "string",
          "minLength": 6,
          "required": true
        }
    }
}

When I'm making a POST request to this endpoint:

localhost:1337/api/auth/local/register

it is possible to register the user without passing the nickname in the body.

How can I set it mandatory during the registration process?

本文标签: registrationMake custom field mandatory while registering a user in StrapiStack Overflow