Setting the name field during signup

On Auth0 Lock v11.4.10 I’m experiencing the same issue as discussed in this thread: Auth0 Lock singup name field - #2 by shayan.memari.

With username / password I’m seeing the “email” field populating the “name” field for newly created accounts on manage.auth0.com. The thread recommended that if “user_metadata.name” was provided it would override this and correctly set the name field. I used additionalSignUpFields to add a new “name” field to my signup form and I’m still seeing the “email” field populating the “name” field.

additionalSignUpFields: [
  {
    name: 'name',
    placeholder: 'your full name',
    icon: `data:image/png;base64,${blank}`,
    validator: (name: string) => {
      return {
        valid: name.length >= 2,
        hint: 'Please enter your full name',
      };
    },
  }
]

Here is an example of the RAW JSON that auth0 is sending on signup. Notice both “name” and “user_metadata.name”

{
    "created_at": "2020-04-06T20:11:12.202Z",
    "email": "emailtest+4@gmail.com",
    "email_verified": false,
    "identities": [
        {
            "user_id": "5e8b8ce0e52f910cdb5a2cae",
            "provider": "auth0",
            "connection": "Username-Password-Authentication",
            "isSocial": false
        }
    ],
    "name": "emailtest+4@gmail.com",
    "nickname": "emailtest+4",
    "picture": "https://s.gravatar.com/avatar/a13a0dc88f263774b119e4ffcc4286c0?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fem.png",
    "updated_at": "2020-04-06T20:11:12.439Z",
    "user_id": "auth0|5e8b8ce0e52f910cdb5a2cae",
    "user_metadata": {
        "name": "Test Here",
        "company": "slkdjflsjf",
        "title": "lkjsldfs"
    },
    "last_ip": "73.93.244.157",
    "last_login": "2020-04-06T20:11:12.437Z",
    "logins_count": 1,
    "blocked_for": [],
    "guardian_authenticators": []
}

Any help or guidance is greatly appreciated.

Hello @draz, Welcome to the Auth0 Community!

Since name is a root profile attribute, you will need to add an additional parameter
in the additionalSignUpFields(storage: "root). Do note I have tested this on v11.23 lock version
You will have to version up from v11.4.10

Can you try like this below:
additionalSignUpFields: [{
name: “name”,
storage: “root”,
placeholder: ‘your full name’
}],

The presence of storage: “root”, will store it in the root user attribute.
Please note only some values can be added in the root attributes.
List here : Auth0 Management API v2

2 Likes

This worked great. Thanks so much.

1 Like

Glad you have it working now @draz!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.