Migration from rules to actions (update user for rest of actions)

Hi,
I started migration of Auth0 rules to actions. We have first rule called linkAccountsWithSameEmailAddress. This rule is for linking users with the same email. For example if provider is auth0 and then also google-oauth2 with the same user, rule concatenate both users to one (and auth0 always as primary).

Link to whole code pastebin. In the end of the rule, we set auth0 user (in code named dbUser) for the other rules as primary. This user is used in the rest rules.

We are also updating user.email_verified and user.app_metadata.is_signup.

      // set db user as main user for remaining rules
      user = dbUser;

      // reset signup state
      user.email_verified = true;
      user.app_metadata = user.app_metadata || {};
      user.app_metadata.is_signup = false;

      return callback(
        null,
        user,
        {
          ...context,
          socialUserId,
          primaryUserId,
          linked: true
        }
      );

How to do the same in actions (update entireevent.user from first action for rest of the actions)?

Thank you.

Hi @ondrej1

Welcome to the Auth0 Community!

Thank you for posting your question. Unfortunately, Actions doesn’t offer global objects; user metadata is updated after all actions are executed. However to pass information across Actions executions, you can use the api.cache.set(). There’s also a documentation about cache limitations → Actions Limitations

Thanks
Dawid