Pre-user-registration: Domain Based Registration action: Limitation the length of the domain list

Hi @serhii.holub

Welcome back to the Auth0 Community!

Thank you for posting your question. You can try to use an Action instead of the plug-and-play action from the marketplace. You can find more related resources about that in this Knowledge Solution → Users are registering with email domains that we don't want to allow

I’m also sharing a small code snippet that would allow you to register from a allowedDomain list,

exports.onExecutePreUserRegistration = async (event, api) => {
  const allowedDomains = ['example.com',]; // Add your allow domains here

  // Extract the domain from the user's email
  const domain = event.user.email.split('@')[1].toLowerCase();

  // Check if the domain is in the allow list
  if (!allowedDomains.includes(domain)) {
    api.access.deny(`domain_not_allowed`,`Registration from domain ${domain} is not allowed.`);
  }
};

Thanks
Dawid