# How to use custom filed to login？

**URL:** <https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888>\
**Category:** Get Help\
**Tags:** login, auth0\
**Created:** [June 4, 2021, 9:49am UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888 "2021-06-04T09:49:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeilShang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neilshang/32/29808_2.png) [@NeilShang](https://community.auth0.com/u/NeilShang)\
**Post date:** [June 4, 2021, 9:49am UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/1 "2021-06-04T09:49:02Z")

</div>

How to use custom filed to login？and I need use Lockjs for login page.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 4, 2021, 4:58pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/3 "2021-06-04T16:58:01Z")

</div>

Hi @NeilShang,

Welcome to the Community!

Do you need a custom field when a user signs up for your app? If so, you can check out the docs here:

> **[Custom Signup](https://auth0.com/docs/libraries/custom-signup)**
>
> How to customize the user signup form with additional fields using Lock or the Auth0 API.

---

<div class="post-metadata">

**Author:** ![NeilShang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neilshang/32/29808_2.png) [@NeilShang](https://community.auth0.com/u/NeilShang)\
**Post date:** [June 4, 2021, 5:08pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/4 "2021-06-04T17:08:54Z")

</div>

Hi @stephanie.chamblee thanks for your response. In fact I need use custom field to login instead of username or email, Do you have any suggestions?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 4, 2021, 5:11pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/5 "2021-06-04T17:11:46Z")

</div>

I would need to research that. Would you mind explaining your use case? For example, is it a username/email in addition to another field, or would it only be this separate field?

---

<div class="post-metadata">

**Author:** ![NeilShang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neilshang/32/29808_2.png) [@NeilShang](https://community.auth0.com/u/NeilShang)\
**Post date:** [June 4, 2021, 5:18pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/6 "2021-06-04T17:18:08Z")

</div>

It’s should be an separate field. This is a unique identifier of the user in our system

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 4, 2021, 5:28pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/7 "2021-06-04T17:28:11Z")

</div>

Unfortunately, Auth0 database connections support only email/username to log in. Is this required because it is possible that there would be more than one account with the same email or username? Otherwise, you can store the user’s unique identifier in app metadata in a post-login action: [Login Flow](https://auth0.com/docs/actions/triggers/post-login)

You can also add this data to the user’s profile info that is stored in the ID Token as a custom claim.

---

<div class="post-metadata">

**Author:** ![NeilShang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neilshang/32/29808_2.png) [@NeilShang](https://community.auth0.com/u/NeilShang)\
**Post date:** [June 4, 2021, 5:42pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/8 "2021-06-04T17:42:22Z")

</div>

Thank you @stephanie.chamblee . I’ll consider your suggestion· I will use username to store this field. But I queried the documentation for Lock.I do not find the way to add custom frontend validator for username. I hope the username to satisfy one of our regular expressions when typed in the front end. Do you have any suggestions?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 4, 2021, 5:52pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/9 "2021-06-04T17:52:52Z")

</div>

On the Lock widget, you can add validation to [additional signup fields](https://auth0.com/docs/libraries/lock/lock-configuration#additionalsignupfields-array-), and you can require that the users use username and not email ([usernameStyle](https://auth0.com/docs/libraries/lock/lock-configuration#usernamestyle-string-)), but there isn’t a lock config option for validating the username field.

What you can do is write a custom template for login ( **Auth0 Dashboard \> Branding \> Universal Login \> Login tab \> Select custom template from template dropdown** ) and add your own frontend validation.

You can also create a pre-registration action that ensures that the user signs up with a username that matches the correct format: [Pre User Registration Flow](https://auth0.com/docs/actions/triggers/pre-user-registration)

---

<div class="post-metadata">

**Author:** ![NeilShang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/neilshang/32/29808_2.png) [@NeilShang](https://community.auth0.com/u/NeilShang)\
**Post date:** [June 4, 2021, 6:00pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/10 "2021-06-04T18:00:32Z")

</div>

Thank you very much for your help, which is very useful to me

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 19, 2021, 6:01pm UTC](https://community.auth0.com/t/how-to-use-custom-filed-to-login/63888/11 "2021-06-19T18:01:29Z")

</div>

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