Account Linking in Actions - How to Keep the User Logged In

Overview
When using an Action to link new passwordless accounts to an existing database account with the same email, the user fails to log in and requires a re-login.
Cause
When linking accounts, the secondary account will cease to exist as its own identity and will instead share the primary account's User ID. 

This can cause issues if the secondary account is what started the login transaction, as, by the end of the Action flow, the secondary User ID no longer exists.
Solution
Make sure when linking within an Action, if what is designated as the primary account is different from the user that began the login flow, to update the login context to the primary user before ending the Action flow, using:

api.authentication.setPrimaryUser(<primary_user_id_here>);

 

Related References

Recommended content

No recommended content found...