Universal Login Custom Template Username Validation Allowing Only Lowercase Alphanumeric Values

My clients have a requirement to restrict usernames to only lowercase alphanumeric values. Because our auth0 implementation is using the universal login systems, I have been looking into the custom login pages. However, I don’t see any reference to the signup page’s HTML and Javascript code. Is this approach to validating a username on signup possible? If not, what are my alternatives to restricting usernames to only lowercase alphanumeric values?

A possible alternative here. I created the following Pre User Registration hook to validate usernames:

module.exports = function (user, context, cb) {
  var response = {};

  response.user = user;

  if(!validateUsername(user.username)) {
     const LOCALIZED_MESSAGES = {
       en: 'Your username must only contain alphanumeric values',
     };
  
     const localizedMessage = LOCALIZED_MESSAGES[context.renderLanguage] || LOCALIZED_MESSAGES['en'];
     return cb(new PreUserRegistrationError('Denied user registration in Pre User Registration Hook', localizedMessage));
  }

  cb(null, response);
};

function validateUsername(un) {
  return /^[0-9a-z]+$/.test(un)
}

However, the password validation message is showing in addition to my custom registration error message. What’s causing the password validation to trigger here?

I have tested with actions instead of hooks and it also triggers the password validation upon receiving the response.

1 Like

I also have seen the same validation error. If there is an error on the username field, the password one is highlighted instead? Is this a known issue?