I want my Auth0 registration form (but not the login form) to require users to enter their password twice to confirm they typed it correctly, but the Lock Configuration Options don't include such a feature.
How can I specify that users must enter their password twice when registering?
You can use the
additionalSignUpFieldsfeature to include an additional 2nd password field, as demonstrated here in the Branding -> Universal Login page:However, this will cause the user's 2nd password field (
repeat_password) to be stored in the user's Auth0 metadata. If this is unacceptably insecure, you can use Javascript to include a 2nd password field which is not part of theadditionalSignUpFields:This uses
setInterval()to wait until theSign Uptab is showing, then injects a 2nd password field after the first one. As the user types into either of the password fields, thevalidatePassword()function is called which determines whether the passwords match; if so, it removes the red border around the fields and displays theSign Upbutton; if not, it adds a red border around the fields and hides theSign Upbutton.It also traps the
Enterkey to prevent users from submitting the form by hittingEnter. This way, the passwords must match before the form can be submitted.