Link Accounts with Same Email Address Rule

When I use the ‘Link Accounts with Same Email Address’ rule my original userid is replaced with the userid of the user that has just logged in. This is problematic as I was storing the original userid in my database.

  1. Is there a version of the ‘Link Accounts with Same Email Address’ rule which maintains the original userid?
  2. If there isn’t how would you suggest I handle this?

Thanks

1 Like

This is strange because according to the linking accounts documentation, “The user_id and all other main profile properties continue to be those of the primary identity.”, meaning that the user_id it is not replaced. Did you make any change in the rule original code? Also, how are you checking that the user_id is replaced? I mean, are you checking it in the dashboard?

@paulimar.angulo The linking documentation you are refering to applies to when you are linking accounts manually. I am trying to link the accounts automatically using the auth0 rule ‘Link Accounts with Same Email Address’. This rule is definitely replacing user_id, I am checking it in the dashboard and I have not modified the rule.

Developers integrating with custom databases rely on the user_id being the same. If there isn’t a rule already could someone at Auth0 create one and post to the official rules or to this forum.

@jculverwell - Did you ever solve this? I also have this issue, and unique id is important since I’m using a custom database + Segment tracking (anlytics). Besides that, did you notice that logins_count field is reset to 1 when you link a new account? And users who link their account to e.g. Google get another “Welcome” email…

I tried writing a rule to handle this, but while it does seem to have merged the account in-place by adding the new identity to the old account, it also appears to have left a “hanging account” around and the new google based account appears half-there and broken.

I also emailed support about this, but I’m attaching my modified rule here in case anyone has any ideas.[link text][1]

I was actually able to find a work-around for this issue, although it’s quite messy, it does work.

Essentially, this solution requires users to first log in with their Google account, then back in with their Auth0 database account. Once that’s done, it merges their google account back into their Auth0 account, and future logins with their Google account work.

[Merge Accounts Rule Hack][1]

We’ve addressed the problem you mention by introducing a new context.primaryUser property that can be set to the user_id of which user should be the primary user.

The Rule here has been updated with this pattern (as of Oct 2nd 2017, the Auth0 templates on the website have not been updated but will be soon):
https://github.com/auth0/rules/blob/master/rules/link-users-by-email.md

See this Github issue for more information.

@paulimar.angulo The linking documentation you are refering to applies to when you are linking accounts manually. I am trying to link the accounts automatically using the auth0 rule ‘Link Accounts with Same Email Address’. This rule is definitely replacing user_id, I am checking it in the dashboard and I have not modified the rule.

Developers integrating with custom databases rely on the user_id being the same. If there isn’t a rule already could someone at Auth0 create one and post to the official rules or to this forum.

Can you share the code of your rule, please?

Hi @paulimar.angulo ,
I have this issue as well. I created a rule and selected the pre-made rule “Link Accounts with Same Email Address while Merging Metadata” (which is similar to the one chosen by @jculverwell “Link Accounts with Same Email Address”).

You can find the code here: Link Accounts with Same Email Address while Merging Metadata - Pastebin.com, but it is the same provided by Auth0 in the dashboard.

The behaviour is the same described by OP: userid changes to the one of the latest login, account creation date and number of login are reset.