A clear explanation of how authentication works when using a custom database connection would be helpful.
For example, on the Database Connections page, on the Custom Database tab, one is able to write custom code to create authentication functionality with an external database.
The login template has parameters for email and password but nothing for username. It’s unclear to me how this is meant to be implemented when a user has the option to login with a username instead of an email.
Similarly, it’s not clear how this information would be stored based on the Create a new user function template.
For Custom Databases, you actually build your own script to retrieve whatever user information you need from the legacy datasource. Once you do that, you build, within the same script, a user profile according to Auth0’s specification.
In this case, instead of attempting to retrieve the email from the legacy datasource, you should attempt to retrieve the username, which you can then put into the Auth0 profile.
The profile would be they copied over to Auth0. If you have Import Mode on, it would also copy the password over, and next time the user authenticates, it would do it against Auth0 and the profile you created in the first login attempt, rather than contacting the legacy datasource.
In the back-end Login script, the template begins with function login(email, password, callback) { . There is a spot for email but not for username. Will Auth0’s form send the input for “username/email” to the email parameter?
Similarly in the Create script, the template begins with function create(user, callback) {. Will the user object here contain both the username and email values from the Sign Up form?
Hmmm I’m still having issues with getting this to work. I made a separate topic because there also seems to be an issue with the Test prompt for the Create function.