Assign Users to Organizations after migration from Custom Database

Ready to post? :mag: First, try searching for your answer.

I need to be able to assign a custom organization, determined from data from the user, after a custom db user migration.

I was reading this article and it seems like exactly what I need: Assign Users to Organizations after auto-migration from Custom Database - Auth0 Community

It states:

To automate this completely, you could implement your code in the Custom Database login script, call your own API from the login script. Once users are created by your login script, call the endpoints shared previously to automatically add the membership to the organization.

Which raises 2 questions:

  1. How can I know when the user is created by the login script. It doesn’t actually create a user, it just returns a profile shaped object. I assume the user creation happens after this.
  2. Is there a way to access the management API from the custom db login script? I don’t see it exposed like in the other Auth0 actions (via the event.api). I guess I could always add machine-to-machine credentials and import the auth0 package.

Do I actually need another post-login or post-user-registration action that does the organization assignment?

Is post-user-registration invoked for custom-db registrations?