How to use custom filed to login?

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

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:

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?

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?

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

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: 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.

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?

On the Lock widget, you can add validation to additional signup fields, and you can require that the users use username and not email (usernameStyle), 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: Actions Triggers: pre-user-registration

1 Like

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

1 Like