# How to prevent login by email when using database connection?

**URL:** <https://community.auth0.com/t/how-to-prevent-login-by-email-when-using-database-connection/9117>\
**Category:** Get Help\
**Tags:** login\
**Created:** [January 3, 2018, 3:16pm UTC](https://community.auth0.com/t/how-to-prevent-login-by-email-when-using-database-connection/9117 "2018-01-03T15:16:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![geoff.battye](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/geoff.battye/32/8906_2.png) [@geoff.battye](https://community.auth0.com/u/geoff.battye)\
**Post date:** [January 3, 2018, 3:16pm UTC](https://community.auth0.com/t/how-to-prevent-login-by-email-when-using-database-connection/9117/1 "2018-01-03T15:16:52Z")

</div>

I have checked ‘require username’ in the settings for my database connection.

The login prompt now says “username/email” and I can log in using either.

I would like to disable email login, so that users have to use their username.

Is this possible, and if so, how?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [January 3, 2018, 5:55pm UTC](https://community.auth0.com/t/how-to-prevent-login-by-email-when-using-database-connection/9117/2 "2018-01-03T17:55:44Z")

</div>

To my knowledge at this time that is not possible, you can customize the prompt text to only say login with username, but that won’t change the fact that both username and email will serve as valid identifiers to complete an authentication. Given that independently of how the end-user logins your applications can get both the username and email associates with that identity it would be interesting if you can update the question with the underlying use case that motivates the need for that restriction.

---

<div class="post-metadata">

**Author:** ![geoff.battye](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/geoff.battye/32/8906_2.png) [@geoff.battye](https://community.auth0.com/u/geoff.battye)\
**Post date:** [January 3, 2018, 9:22pm UTC](https://community.auth0.com/t/how-to-prevent-login-by-email-when-using-database-connection/9117/3 "2018-01-03T21:22:45Z")

</div>

Thanks for your reply. My use case is that I am exploring possibilities for using Auth0 in my client’s banking/investment site, which already assigns users an ID, and for which my client is considering requiring client ID and password for login, as seems to be fairly standard in the banking sector. E.g. see [security - Why do financial institutions use usernames instead of emails for login? - User Experience Stack Exchange](https://ux.stackexchange.com/questions/62570/why-do-financial-institutions-use-usernames-instead-of-emails-for-login)

---

<div class="post-metadata">

**Author:** ![geoff.battye](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/geoff.battye/32/8906_2.png) [@geoff.battye](https://community.auth0.com/u/geoff.battye)\
**Post date:** [January 3, 2018, 9:23pm UTC](https://community.auth0.com/t/how-to-prevent-login-by-email-when-using-database-connection/9117/4 "2018-01-03T21:23:33Z")

</div>

So it’s not possible to determine whether user supplied email or username in a rule?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [January 17, 2018, 12:26am UTC](https://community.auth0.com/t/how-to-prevent-login-by-email-when-using-database-connection/9117/5 "2018-01-17T00:26:01Z")

</div>

I don’t think there is a reliable way; in some authentication flows like the resource owner password credentials grant it could be possible, but in others I don’t think so. Unless you use a custom database connection; in this case, although it would be expected that an end-user would have an email associated with it the actual credential validation is performed through custom scripts you control so after receiving the credentials you could treat an attempt to use email as an invalid authentication.

---

<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:** [July 25, 2019, 9:38am UTC](https://community.auth0.com/t/how-to-prevent-login-by-email-when-using-database-connection/9117/6 "2019-07-25T09:38:44Z")

</div>


