# Using "username" in the context of a "custom database"

**URL:** <https://community.auth0.com/t/using-username-in-the-context-of-a-custom-database/96207>\
**Category:** Get Help\
**Tags:** automatic-migration, user-management\
**Created:** [December 11, 2022, 6:35pm UTC](https://community.auth0.com/t/using-username-in-the-context-of-a-custom-database/96207 "2022-12-11T18:35:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![connectionreset](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/connectionreset/32/41873_2.png) [@connectionreset](https://community.auth0.com/u/connectionreset)\
**Post date:** [December 11, 2022, 6:35pm UTC](https://community.auth0.com/t/using-username-in-the-context-of-a-custom-database/96207/1 "2022-12-11T18:35:34Z")

</div>

Just searched the forum for my problem on _custom databases_ related to the use of a `username` (“Requires the user to provide a username in addition to email.”) There are already entries on this topic, but no apparent solution – or at least explanation.

My question:  
In the _Database Action Scripts_, only the user’s email address is ever passed in the functions. Especially if I have set the username-checkbox, I would actually always expect the “username” here.

Here the method signature of the action `Get User` is:

`function loginByEmail(email, callback) {}`

Also the function of `Change Password` always gets passed only the email address:

`function changePassword(email, newPassword, callback) {}`

Or am I missing something obvious?

Thanks for your time,  
Peer

---

<div class="post-metadata">

**Author:** ![david\_wisecarver](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/david_wisecarver/32/37472_2.png) [@david\_wisecarver](https://community.auth0.com/u/david_wisecarver)\
**Post date:** [December 15, 2022, 11:06pm UTC](https://community.auth0.com/t/using-username-in-the-context-of-a-custom-database/96207/3 "2022-12-15T23:06:04Z")

</div>

Hi @connectionreset,

Welcome to Auth0 Community!

If you have `Requires Username` enabled for a custom database connection, you will need to then add the the `username` property to the [Login](https://auth0.com/docs/authenticate/database-connections/custom-db/templates/login) and [Get User](https://auth0.com/docs/authenticate/database-connections/custom-db/templates/get-user) scripts.

> **[Custom Database Action Script Execution Best Practices](https://auth0.com/docs/authenticate/database-connections/custom-db/custom-database-connections-scripts/execution#create-action-scripts)**
>
> Learn about best practices for custom database action script execution.

You should see an error message “DB Login Custom script: username is required” if you have it missing from these scripts when `Requires Username` is enabled.

Hope this helps!

Thanks,  
Dave

---

<div class="post-metadata">

**Author:** ![connectionreset](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/connectionreset/32/41873_2.png) [@connectionreset](https://community.auth0.com/u/connectionreset)\
**Post date:** [December 18, 2022, 5:12pm UTC](https://community.auth0.com/t/using-username-in-the-context-of-a-custom-database/96207/4 "2022-12-18T17:12:04Z")

</div>

Hello Dave,

thank you very much for your answer.

Have now implemented a solution based on “Organizations”. Think I will stick with it.

Kind regards  
Peer

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 5:24pm UTC](https://community.auth0.com/t/using-username-in-the-context-of-a-custom-database/96207/5 "2022-12-21T17:24:21Z")

</div>


