Auth0 Home Blog Docs

After linking accounts in the context of a rule pipeline, is there a way to continue the pipeline with the 'master' user (the user whose account has become the master account)?



For this example, assume original_user is the account that was used to authenticate the first time, and current_user is the current user in the rule pipeline. Both original_user and current_user have the same e-mail accounts, so they can be linked, and original_user has some existing app_metadata properties.

We have a rule pipeline and one of the rules links accounts with the same e-mail address. Our problem is after the accounts are linked, the current_user app_metadata is empty and we’d like to use the original_user’s app_metadata.

Is there a way to use the updated user (e.g. original_user + current_user linked account) in the pipeline after the link rule is executed successfully? Or should we simply set the current_user app_metadata to equal the original_user’s app_metadata after linking?

It seems that in a perfect world, after the linking has been successfully executed within the context of the rule pipeline, the “user” object would automatically be representing the original_user as described above. Otherwise, the “current_user” is a lame duck from that point forward (to use a political analogy)


Using the context.primaryUser construct you can already influence which user identity should be used to process the final authentication/authorization response. However, like you mentioned, the user object in the rules pipeline itself will not be modified so other rules after linking may not have the whole picture. If you’re in a situation where your requirements mandate that account linking rule is not the last step of the rule pipeline then your suggestion of manually overriding the fields is indeed possible although I could not find formal documentation about such possibility.