# Migrate Rules to Action - context.primaryUser

**URL:** <https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128>\
**Category:** Get Help\
**Tags:** other, missing-category\
**Created:** [April 3, 2024, 5:18pm UTC](https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128 "2024-04-03T17:18:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dariom](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dariom/32/56100_2.png) [@dariom](https://community.auth0.com/u/dariom)\
**Post date:** [April 3, 2024, 5:18pm UTC](https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128/1 "2024-04-03T17:18:24Z")

</div>

I’m trying do understand how to migrate old rules to the new actions implementation.  
I understand that most of the read only data found in the old rule `context` are now into the `event`… but how can I know which is the `context.primaryUser` id now?

Is now the `user.user_id` (in the old rules `user.user_id` it could be different from `context.primaryUser`)?

How can I check now, which Identity the user used to log in, and which is the primary one?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [April 3, 2024, 5:50pm UTC](https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128/3 "2024-04-03T17:50:53Z")

</div>

Hi @dariom,

Welcome to the Auth0 Community!

If you are looking to link user accounts with Actions, I recommend referring to our [Link User Accounts](https://auth0.com/docs/manage-users/user-accounts/user-account-linking/link-user-accounts#account-linking-with-actions) documentation.

Let me know if you have any questions.

Cheers!  
Rueben

---

<div class="post-metadata">

**Author:** ![dariom](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dariom/32/56100_2.png) [@dariom](https://community.auth0.com/u/dariom)\
**Post date:** [April 3, 2024, 6:15pm UTC](https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128/4 "2024-04-03T18:15:54Z")

</div>

I already checked these docs, but no, i’m just trying to migrate old rules to news where some decisions where made based on the current identity / primary identity.

So my question is just basically to know if there is any way, using the post login action event, to know which identity was used / which is the primary one?

---

<div class="post-metadata">

**Author:** ![spoudel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/spoudel/32/51376_2.png) [@spoudel](https://community.auth0.com/u/spoudel)\
**Post date:** [April 4, 2024, 12:31am UTC](https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128/5 "2024-04-04T00:31:59Z")

</div>

You can use **event.connection** to know about what connection was used to authenticate and you could use **evet.user.identities** to get info from the identity provider.

You might find more relevant information in the event object definitions for the action triggers here: [Actions Triggers: post-login - Event Object](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/event-object)

---

<div class="post-metadata">

**Author:** ![dariom](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dariom/32/56100_2.png) [@dariom](https://community.auth0.com/u/dariom)\
**Post date:** [April 4, 2024, 7:47am UTC](https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128/6 "2024-04-04T07:47:35Z")

</div>

Ok, thank you. So, to recap now the `user.user_id` refers to the old `primaryUser`, and the old `user` is not available anymore but can filter `event.user.identity` by `event.connection` to know which identity was used.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 18, 2024, 7:48am UTC](https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128/7 "2024-04-18T07:48:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [May 6, 2024, 4:22pm UTC](https://community.auth0.com/t/migrate-rules-to-action-context-primaryuser/131128/8 "2024-05-06T16:22:31Z")

</div>

Hi @dariom,

Yes, that’s correct! If you look under the primary user’s identities array, you should find all the linked identities to that account.

Cheers,  
Rueben
