Account Linking Did Not Occur Because loginsCount = 2 on First Apparent Login

Overview

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.

Applies To
  • Account Linking
Cause
If a user triggers the Account Linking Extension and then abandons the account linking process (ex., they give up on trying to enter the credentials for the second account and close the tab), no log is generated for the initial successful login. If that session expires, the next login attempt will show loginsCount:2, even though it appears to be the first log they have of a Successful Login. 
Solution

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.

Recommended content

No recommended content found...