Account Linking Did Not Occur Because loginsCount = 2 on First Apparent Login
When using the account linking extension to link user accounts, there are times when a user should have been prompted to link accounts but did not. This article explains why, in these cases, it looks like the user's first log with a "Successful Login" is showing loginsCount: 2.
- Account Linking
loginsCount:2, even though it appears to be the first log they have of a Successful Login. As Rules reached its end of life in 2024, the recommended approach would be to disable the extension and migrate to handling account linking in an action that uses an app_metadata state value instead of loginsCount to determine if linking should occur. Here is an example action from our docs that also handles the redirect for a user to enter the credentials of the second account: Example account linking with Actions.
The other option would be to modify the rule automatically generated from the Account Linking Extension to use an app_metadata state value similar to how the action example does instead of context.stats.loginsCount. For example, update the user's app_metadata on line 135 in the rule, then change the firstLogin() function on line 68 to check if the app_metadata value exists. Here is a link to our docs showing how to manage metadata in Rules if you use this option: Manage Metadata with Rules.