Signup user and add app_metadata

I have a question that has been asked before, but I cannot see the answer im looking for.

I am using the auth0.js SDK to signup a user from a custom html form.

In my signup form I have a custom field named “company_name”.
I want to store this “company_name” in the users app_metadata.

But the auth0.signup function does not allow me to post app_metadata.
It only allows me to post user_metadata.

So after Googling for some hours without a solution, my only solution is some kind of a hack.

I can create a hook that creates app_metadata from the user_metadata on a Pre User Registration

   module.exports = function (user, context, cb) {
      var response = {};
      response.user = user;
      response.user.app_metadata = {company_name: user.user_metadata.company_name};
      cb(null, response);
  };

But there must be better solution than this?

There is another solution but that requires additional steps and does not work when a user signs up.
Like this one: https://auth0.com/docs/users/update-metadata-with-the-management-api#

Does anyone have any tips on how to solve this?

Hello, @thomasjk - welcome to the Auth0 Community!

This is actually how Auth0 is intended to work during signup: Custom Signup

If you want any additional fields to be present as soon as the user has been created, this can be done via the Hook, just like you are doing it at the moment.

Ok, then i know. Thanks for the quick reply @joseantonio.rey

1 Like

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