Can you pass user_metadata in a call to Auth0.js signupAndLogin method?

We are converting from using Lock to using a custom login with the Auth0.js Web SDK. With Lock, we’ve defined several custom fields (first name, last name, etc) that are mandatory for sign up.

Is it possible to create the user’s account and pass in custom fields (via user_metadata) in one single call?

The signupAndLogin method only seems to take username/password, and I’d have to make a subsequent call to update the user’s profile, which would be tricky with a redirect in between.

You can pass a user_metadata object into the method in question in order to immediately assign user metadata to the created user. Both the method signupAndLogin available through Auth0.js and the Lock additional custom fields functionality make use of the same underlying endpoint so they both can leverage the same feature set.

For example:

webAuth.redirect.signupAndLogin({
    // ... other required fields
    email: "user4@example.com",
    password: "user4",
    user_metadata: {
        full_name: "User IV",
    }
}, function (err) { /* ... */ });

I also made a request for the documentation of the Authentication API endpoint in question (signup) to be updated to reflect that it accepts a user_metadata parameter.

1 Like