Custom database script with username

I’m trying to auto-migrate users from my custom datastore to auth0. I have enabled the “import users to auth0”-setting and defined custom database scripts for login and get-user with the following signatures:

function login(email, password, callback)
function getByEmail(email, callback) 

However, in my database, usernames are not email addresses, so I have enabled the “Requires username” checkbox:

When enabling this I get the following error in the log: DB Login Custom script: username is required, please update the import user script in the connection settings.

This makes sense, but I’m not sure exactly what part of the script I should modify? Should the method signature be changed, and if so, to what? Should the object passed in the callback function be changed?

It should be the second option you mentioned; by requiring a username your scripts will need to return a username property in the profile object that they pass to the callback. Also have in mind that as far as I’m aware requiring a username does not remove the requirement of database connections users having an email address (and a unique one) so do have that under consideration.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.