Post User Registration Flow

The Post User Registration Flow runs after a user is added to a Database or Passwordless Connection.

Diagram of the Actions Post User Registration Flow.

Actions in this flow are non-blocking (asynchronous), which means the Auth0 pipeline will continue to run without waiting for the Action to finish its execution. Thus, the Action's outcome does not affect the Auth0 transaction.

Triggers

Post User Registration

The post-user-registration triggers runs after a user has been created for a Database or Passwordless connection. This trigger can be used to notify another system that a user has registered for your application. Multiple actions can be bound to this trigger, and the actions will run in order. However, these actions will be run asynchronously and will not block the user registration process.

References

  • Event object: Provides contextual information about the newly-created user.

  • API object: Provides methods for changing the behavior of the flow.

Common use cases

Notify Slack when a new user registers

/**
* Handler that will be called during the execution of a PostUserRegistration flow.
* 
 * @param {Event} event - Details about the context and user that has registered.
 * @param {PostUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of post user registration.
 */

exports.onExecutePostUserRegistration = async (event, api) => {
  const { IncomingWebhook } = require("@slack/webhook");
  const webhook = new IncomingWebhook(event.secrets.SLACK_WEBHOOK_URL);

  const text = `New User: ${event.user.email}`;
  const channel = '#some_channel';

  webhook.send({ text, channel });
};

Was this helpful?

/

Store the Auth0 user id in a remote system

A post-user-registration Action can be used to store the Auth0 user ID in a remote system.

/**
* Handler that will be called during the execution of a PostUserRegistration flow.
* 
* @param {Event} event - Details about the context and user that has registered.
* @param {PostUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of post user registration.
*/

const axios = require("axios");

exports.onExecutePostUserRegistration = async (event, api) => {
  await axios.post("https://my-api.exampleco.com/users", { params: { email: event.user.email }});
};

Was this helpful?

/