ACUL SignupOptions Interface Fails to Pass Phone Number Property to Auth0

Overview

The phone number property fails to pass to the Auth0 user object when using the Auth0 Custom Universal Login (ACUL) SignupOptions interface because custom attributes require explicit mapping. Create a Pre-User Registration Action to capture the property from the request body and set it in the user metadata to resolve the issue. When using the standard payload from the Software Development Kit (SDK), the phone string populates before sending, but the data does not reflect in the Auth0 user object:

export interface SignupOptions {
  email?: string;
  username?: string;
  phone?: string;
  captcha?: string;
  [key: string]: string | number | boolean | undefined;
}

Applies To

  • Auth0
  • Auth0 Custom Universal Login (ACUL)
  • SignupOptions
  • Pre-User Registration Actions

Cause

Auth0 does not automatically map custom properties passed through the SignupOptions interface to the root user object during registration.

Solution

How is the phone number property captured and set on the user metadata?

 

When passing custom fields through the Universal Login interface, the inputs on the custom frontend form must be prefixed with ulp- (for example, ulp-phone or ulp-phone_number) so they are not stripped by the server.

Auth0 exposes information sent through the SignupOptions object in the Action under event.request.body with the ulp- prefix intact. Create a Pre-User Registration Action using the provided code template to extract the phone property from the request body and attach it to the user metadata:

exports.onExecutePreUserRegistration = async (event, api) => {
  // Extract the phone value sent from the frontend ACUL SignupOptions
  const phone = event.request.body['ulp-phone'] || event.request.body['ulp-phone_number'];

  if(!phone) {
    api.validation.error("invalid_payload", "Missing Phone Number");
    return;
  }
    // Explicitly attach it to the newly created user's metadata
    api.user.setUserMetadata("phone_number", phone);
};

 

Recommended content

No recommended content found...