Update Made in Post-User Registration Action Not Available in Post-Login Action

Problem statement

When a user signs up, a Post User Registration Action executes which should add a role to the user’s profile. In a subsequent Post-Login Action, this Role is processed further. Intermittently it seems the Role set in the Post-User Registration Action is not available in the Post-Login Action.

What is the reason for the inconsistent behavior and what would be the recommended approach for this use case?

Cause

There is a subtle but important difference between the Post-User-Registration and Post-Login Action. The Post User Registration Action is described like the following:

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.

Meanwhile, the Post-Login Action has the following execution behavior:

Actions in this flow are blocking (synchronous), which means they execute as part of a trigger’s process and will prevent the rest of the Auth0 pipeline from running until the Action is complete.

This difference in behavior is the underlying reason behind a user update in a Post-User-Registration Action being intermittently available in a Post-Login Action. Occasionally the update in the Post-User-Registration Action would complete prior to the Post-Login Action executing, but due to the asynchronous nature of that trigger, it is not guaranteed to finish before the Post-Login trigger runs.

Solution

When performing updates to a user, or performing other business logic that needs to be completed during an authentication transaction, it is recommended to use a Post-Login Action.

In this instance, moving the logic from the Post-User-Registration Action to the Post-Login Action, so all user updates could be performed within the Post-Login Action pipeline, resolved the issue of the role not being available.