How to authenticate with username and password

Hi team,

I am using a custom database, where my database uses a username[not email] and password to authenticate the user. Now how can we pass the username in the login script? I am disabling import user so all the get and create script will execute accordingly

Hi @anish.subedi,

You should be able to use the email in the login script as either the email or username of a user, and then include the username in the profile returned. I should note that if you do decide to turn import mode on, these users will need a unique email address for their Auth0 profile as that is a requirement.

1 Like

Hi @david_wisecarver ,

Thank you for your response. I just want username property in getuser script, login script within the script template you have provided.


Because while triggering create operation it triggers the following script asynchronously. Now in get user I need to pass get used by any other user attribute[suppose I have a username in my external db] but the template doesnt contain that field. So how to catch that value within the get script

Yes, additional logic is necessary to add in the get user script, login script, but how to add that logic, auth0 has given us the template where only email can be used, and replacing and adding username parameter is not working here.

`function getUser(email, callback) {

// Send user identifier to external database API
let options = {
url: “https://example.com/api/search-users”,
body: {
email: email
}
};`

````Preformatted text`

Please please need more details on the implementation.

Hi @david_wisecarver ,

Actively waiting for your response.

Hi @anish.subedi,

If you are wanting to create new users with the create script, you will need to include a unique email for the user as well. If you have import mode off and Require Username enabled, the get_user script will actually only use the email. We have a backlog item in to address that the get_user script does not run again with a username, though we do not have an ETA for that at the moment. The workaround would be to use the get_user script to validate existing emails, but would only validate for existing username in the create script logic .

I also wanted to share this link to another community post that covers how your Custom DB scripts to be able to handle the email parameter being passed as either an email or a username: Username does not work for custom mongodb connection

1 Like

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