I am using auth0 API. So far, I was unable to find any instruction or guide on this. Is there any way to set user name as required field and throw validation error if it is not provided?
Hi Anit!
To clarify, do you want to make the user’s “name” a required field or their “username”?
To require the username, you can navigate to Connections > Database in the dashboard and turn on Requires Username in the database settings.
If it is name, then the email is set as the name by default in the Normalized User Profile.
To require name as a sign up field, you can add the field as an item in the additionalSignupFields
in your lock configurations in Universal Login > Login (must turn on “Customize Login Page”):
var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
additionalSignUpFields: [
{ name: 'name', placeholder: 'name', storage: "root" }
],
Once the Universal Login code includes “name” as a signup field, the user will not be able to sign up without filling out the name field.
If you are not customizing your Universal Login page using lock.js, but instead using the Authentication API, then you can send the name in the signup call. When you send “name” in the request body, then it will require a string with at least one character for the value. If “name” is omitted from the request body, then the email will be used as the user’s name.
I hope that helps!
Stephanie
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.