メインコンテンツへスキップ
ユーザー登録後トリガーは、ユーザーがデータベースまたはパスワードレス接続に追加された後に実行されます。
Diagram of the Actions Post User Registration Flow.
このフローのアクションは非ブロック(非同期)であるため、Authパイプラインの実行はアクションの完了を待たずに継続されます。そのため、アクションの結果は、Auth0のトランザクションに影響しません。

トリガー

ユーザー登録後

post-user-registrationトリガーは、ユーザーがデータベースまたはパスワードレス接続用に作成された後に実行されます。このトリガーを使用して、ユーザーがアプリケーションに登録したことを別のシステムに通知できます。このトリガーには複数のアクションをバインドでき、アクションは順番に実行されます。ただし、これらのアクションは非同期で実行されるため、ユーザー登録プロセスがブロックされることはありません。

リファレンス

一般的なユースケース

新しいユーザーが登録されたらSlackに通知する

/**
* 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 });
};
このアクションが正常に動作するには、アクションがSLACK_WEBHOOK_URLという名前のシークレットを含み、@slack/webhooknpmパッケージに依存しなければなりません。

Auth0ユーザーIDをリモートシステムに保存する

post-user-registrationアクションを使用して、Auth0ユーザーIDをリモートシステムに保存できます。
/**
* 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 }});
};
axiosなどのnpmライブラリーを使用する場合は、そのライブラリーをアクションに依存関係として追加しなければなりません。詳細については、「初めてアクションを作成する」の「依存関係を追加する」セクションをお読みください。
I