Account linking using Action during Post User Registration

Hi everyone,

I’m trying to implement a seamless account linking routine, but still without success, although I’ve found some success stories from the community like the one from Alexab.

I’m doing the whole process using an Action during Post User Registration flow, and the code can be consulted in this repository on GitHub. I wrote this integration test, and I could manually assert that the logic was working as expected. To test it manually, I created two users with the same email address, then executed the test. So far, so good!

Before linking:

After linking the accounts (the linked account shows 2 identities in its properties):

The problem appeared when I started a database from scratch and created the two users, testing the Action on Auth0 instead of doing it locally. When I make the second user during the registration flow, I receive the error The user does not exist.

Testing it locally with a small express server with the help of Ngrok and Axios to invoke my endpoint, everything seems fine, but the Management API returns the same error.

My test case:

  1. Create a user using email and password, and then authenticate it.
  2. Confirm user’s email.
  3. Log in using passwordless with the same email from the user at step 1.
  4. The Action is called, and the error The user does not exist is raised.
  5. Enter the provided code that had been received by email.
  6. Authentication flow is finished.

It seems that between steps 3 and 4, the user is not entirely created in the database (is it waiting for the code confirmation?), though I could receive his ID in the Action.