GetUser breaks create user ability

So we implemented GetUser script with automatic migraiton enabled in a db connection
it checks if user exists by email in external db otherwise fails

But the issue now is: we try to create a new user in auth0 using UI or using mhmt api (that does not exist in the legacy db), this fails because of course the user does not exist in legacy db

How we do get around this?

so instead of this

try { check if exists in external db, return profile } else { fail }

we now do

try { check if in external db, return profile } else { return callback(null, null) }

and now it works

oh but we still have issue

if external user exists now we cannot create user since it says user already exists

this is a blocker for us because how we can ever proceed with create_user (we use python api to do that), if we even invoke GetUser during user_creation? Maybe I am missing sth but that fact that GetUser gets invoked at all in this case is a surprise to me (we have automatic migration enabled)

  • during reset pwd, we want this check to succeed for existing users in external db, so that user can reset pwd without having ever logged in to auth0
  • during create_user, we want to proceed regardless of whether external db user exists.

the only workaround I can think of is that we temporarliy make it look like the external db user does not exist and once we are done with user creation in auth0 we restore that user. This hack would not be needed if getUser was never invoked during create_user