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.
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
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.
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.