Migration fields from rules to actions

Hi,

I just started process to migrate our Auth0 rules to actions and I was able to map most of the field, but I still have problems with these:

  1. Access auth0.baseUrl (used in rules).
  2. Access user.user_id (used in rules).
  3. Access updated context in different action.

Access auth0.baseUrl (used in rules).

We have for example setup request in current Auth0 rule to const url = ${auth0.baseUrl}/users` address. Is it possible to access auth0.baseUrl somehow also in Actions? If not, I thought about set it as environment variable (SECRET).

Access user.user_id (used in rules).

We have user.user_id field used a lot in our rules. For example with updating app metadata : auth0.users.updateAppMetadata(user.user_id, user.app_metadata)
How to replace user.user_id in this situation?

Access updated context in different action.

Third question is about accessing updated context fields in another action. In one auth0 rule we update context object by:

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

and under different rules we are accessing context.linked or context.primaryUserId. How to do the same with actions?

Thank you for help

Hi @ondrej1!

I understand you are migrating your Rules to Actions!

  1. You can add a secret to any action by following the steps under the “Add a Secret” section: Write Your First Action. Unlike Rules, you cannot add global variables that all Actions can access. You will need to add any variable an Action requires to each Action’s secrets.
  2. You can access the user_id in an Action with event.user.user_id. Please see this doc for more information on the event object in a post-login Action: Actions Triggers: post-login - Event Object
  3. To access the primary connection’s user_id, you can use event.user.identities[0].user_id.

Please let me know if you have any additional questions or run into any issues migrating to Actions!

Best,

Mary Beth

Hi marybeth.hunter,

thank you for your answer, but I am still struggling with question about updated context in different action, what you didn’t answer.

I will try to describe situation more:
We have first role called linkAccountsWithSameEmailAddress. In the end of this rule, we have update of context with some new fields:

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

Then we have another rule running right after linkAccountsWithSameEmailAddress called handleSocialSignups where we check context.linked. But how to pass these additional field from one action to another?

Link to javascript rule pastebin.

Thank you for your help.

Hi @ondrej1!

Thank you for your reply! I apologize for missing the bit about the updated context. Referencing this migration limitation doc, the passing of variables between Actions is not supported. If you have Rules that depend on passing of state or variable data between one Rule to another, you can consolidate those Rules into a singular Action.

Please let me know if you have any additional questions!

Thanks,

Mary Beth

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.