How do I configure custom forms during the sign up process?

I was planning on using this as a reference but ran into an issue where I can’t make API calls.

I tried following the steps outlined but ran into an issue when I went to create a partial via this API

https://tenant/api/v2/prompts/signup/partials

I got the following error:

{“statusCode”:400,“error”:“Bad Request”,“message”:“This feature requires at least one custom domain to be configured for the tenant.”}

I presume I have to sign up for a plan to implement this.

This should work for the terms and conditions but am unable to test as I have yet to sign up for a plan.

  api.user.setUserMetadata("termsAcceptance", terms);

Before I do this, I’d like confirmation on the proper implementation of a marketing optin on user sign up.
For the marketing Opt-In, is there an event for post user registration? The example only shows: onExecutePreUserRegistration

Do actions allow for post requests via fetch or XMLHttpRequest to a third-party link? Will I run into any CORS issues?

Is the user email available via the api.user object or do I need to use the event.request object in the post registration event?

I’m presuming Actions are JS scripts that can be executed during a flow but unsure if they run in a user’s browser or if they run in a node instance on Auth0’s servers.

Is this the best approach or is there a better way with the new Universal Login? I need to take the user’s email address and if they opt-in send it to a marketing provider via a REST API call.

Hey there @whoareyou welcome to the community!

That is correct, you’ll need to configure a custom domain which does require a paid subscription.

The event.request.body object is not available in a Post User Registration Action, Only Pre User Registration and Post Login.

As Actions exist in a Node environment, you can certainly use fetch or other similar Javascript libraries. As Actions are run server-side, you won’t need to worry about CORS issues.

You should be able to utilize event.user.email

You are correct in that Actions are run during specific auth transactions - They run in a node instance on Auth0’s servers as opposed to a user’s browser.

Actions are indeed the best way to achieve what you are looking to do :slight_smile:

2 Likes

Thank you for the quick follow up!
I found some documentation today that is directly applicable for future users needing this.
I should be able to use the code found at the bottom of this to resolve this functionality.
https://auth0.com/docs/customize/actions/flows-and-triggers/post-user-registration-flow

I should be able to perform a request to the provider using this exact code.

const axios = require("axios");

/**
 * @param {Event} event - Details about registration event.
 */
exports.onExecutePostUserRegistration = async (event) => {
  await axios.post("https://my-api.exampleco.com/users", { params: { email: event.user.email }});
};
1 Like

No problem, happy to help!

Thanks for sharing - Yes! That will work to ping an external service and is will work out of the box, no custom domain required.

Hmm.
I deployed a couple of actions today, one pre-registration and one post registration and I couldn’t actually trigger them. Do actions appear in the log? For testing purposes, I deleted the user from the auth0 database. Then I went through my usual login flow that auto-creates users when using a identity provider. It created the user without issues but neither action actually triggered on the user. Note: I’m using an sdk, do the actions need to be specified there or should actions activate on every flow execution regardless of source? Note: When I ran the “Test” function on the action, it appeared on the logs.

1 Like

Hey @whoareyou !

Actions details should appear in logs assuming they are triggered - You do not need to do any config SDK side:

Pre and post user registration actions will only run for Database and Passwordless connections, not Social. The other thing I might check is that you have them properly attached to the flow - You can check by going to Actions → Flows → Pre/Post Registration:

I was testing using Google, which I presume is a Social connection. So you’re saying I can’t do any custom forms during signup for any identify providers besides Auth0’s database connections? So then how can one get terms and conditions accepted upon registration?

Google is indeed a social connection - Unfortunately, there are technical complexities related to capturing data in the social section of prompts. Federated connection “signups” are not processed in the same way as database connection signups; they are essentially treated like logins and therefore only Post Login Actions will run. Auth0 doesn’t control the transaction when an end-user logs in via an enterprise or social service and user data is provided to Auth0 by the enterprise/social connection upon successful authentication.

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