After Account Linking SSO Does Not Work as Intended

Problem statement

After linking user accounts in an action or rule, the authentication is not completed successfully, and SSO does not work.

Cause

This can happen if the user logging in has been linked as a secondary user and a code to assign the linked primary user as the active user session is not called.

Solution

This can happen if the current user logging in has been linked as a secondary user. Then, within the rule or action, the following code needs to update the user with the linked primary user ID.

Rule;

context.primaryUser = thePrimaryUserID

Action;

api.authentication.setPrimaryUser(thePrimaryUserID);