TypeError on pre-user-registration: Cannot read properties of undefined (reading 'render')

I am using Forms and Flow to set up additional details for sign-up. I made a form that asks the user trying to register for additional details that will automatically update the metadata. For the Flow, I have selected for the flow to be executed on pre-user-registration. However, while pasting the “render” code given by forms, I got an error that said “prompt” in “api.prompt.render(FORM_ID);” was undefined. However, this is not an issue for the on-log-in state, but I am only trying to add this flow for user registration.

So, when I tried to register a new user, I got an “Extensibility error” on the Password box and got a TypeError on logs.

Please help.

hey @ngitman :wave:

Forms for Actions is currently only available for the Post-Login flow, you cannot use it for the Pre User Registration flow. See the “Restrictions and limitations” in this documentation - Render Forms using Actions

If you need to render forms on user registrations only, you can add logic to a Post-Login action to detect if it is the user’s first login request using something like below:

exports.onExecutePostLogin = async (event, api) => {
    // Skip user with more than one login count, or if this is a refresh token exchange or silent auth request
    const not_first_login = event.stats.logins_count > 1 ||
                            event.transaction?.protocol === 'oauth2-refresh-token' ||
                            event.request.query?.prompt === 'none';

    if (not_first_login) {
        return;
    }

    // Add your logic to render the form
}

exports.onContinuePostLogin = async (event, api) => {
  // Add your logic after completing the form
}

Note: this is not “official” code from Auth0 by Okta, so please test to ensure it fits your needs ^

Hi, this worked, thank you!

1 Like

Great to hear this works for you! :slight_smile: