Migrate Rules to Action - context.primaryUser

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?

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 documentation.

Let me know if you have any questions.

Cheers!
Rueben

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?

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

1 Like

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.

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

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