Add name to signup form

Hi,

I added the full_name as to the signup form as explained here: Lock Configuration Options

However, the name displays in the metadata options. I want it to display under “Name” in the user details section.

How can this be completed?

Hi @somekh.dave,

AFAIK you will not be able to update the root attributes on signup using lock.

You can however, use the metadata to set the name attribute in a rule.

Check that the metadata and the attribute don’t match, and then make a call to the management API to change the root attribute.

Something like this:

function (user, context, callback) {

  if (!user.app_metadata.name === user.name) {
    var ManagementClient = require('auth0@2.19').ManagementClient;
    var management = new ManagementClient({
      token: auth0.accessToken,
      domain: auth0.domain
    });

    var params = { id: user.user_id };
    var data = { name : user.app_metadata.name };

    management.users.update(params, data, function (err, users) {
      if (err) {
        //handle err
      }
      console.log(user);
      callback(null, user, context);
    });
  };

  callback(null, user, context);
};

I haven’t tested this, but it should get you most of the way there.

Hope this helps!
Dan

2 Likes

Thanks Dan! That worked

2 Likes

Glad to hear it! Let us know if you have any other questions.

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