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

Reference

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

Common use cases

Notify Slack when a new user registers

/**
 * @param {Event} event - Details about newly created user.
 */
exports.onExecutePostUserRegistration = async (event) => {
  const slack = require('slack-notify')(event.secrets.SLACK_WEBHOOK_URL);

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

  slack.success({
   text: message,
   channel: channel
  });
};

For this Action to execute properly, the Action must contain a secret named SLACK_WEBHOOK_URL and must have a dependency on the slack-notify NPM package.

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.

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 }});
};

To use an NPM library like axios, you must add the library as a dependency to the Action.