How to Pass Variables between Actions in the Login Flow per User

Problem statement

This article provides a solution to pass variables between Actions that can be used for the user-level attributes.


The cache is suitable mainly for global variables that need to be accessed across Actions, as it allows 20 entries that can be cached per Trigger. This limits cache usage for high-traffic tenants, with many users logging in parallel. Instead, for variables that need to be passed around Actions, the following workaround may help:

  1. Create the temporary variable in either the user’s app or user metadata. E.g.,
api.user.setUserMetadata("tmp1", 1);
api.user.setAppMetadata("tmp2", 2);
  1. Then, these variables can be accessed with the event.user.user_metadata or event.user.app_metadata object.
  1. In the last Action, the temporary metadata attribute must be set to null and then to undefined. This helps avoid storing these variables in the user profile and prevents the tenant from unintentionally consuming the management API.
api.user.setUserMetadata("tmp1", null);
api.user.setUserMetadata("tmp1", undefined);

api.user.setAppMetadata("tmp2", null);
api.user.setAppMetadata("tmp2", undefined);