Stop user registration via Pre-registration Action flow

I followed the Pre-registration action flow and just added this line to see if user registrations go through or not.
api.access.deny('no_signups_from_north_america', userMessage);

Looks like no matter how I return out or use this, the registration goes through. I want to understand if I am missing something or is there a different way to achieve this.

A brief about my setup

  • Pre-registration action to stop User registration with the same Email ID
  • ULP page setup in a React app
  • Social + Username_Password connection types

I also tried to explicitly call the getUserByEmail API inside the Pre-registration hook to deny registrations but that also isn’t work. Can anyone please help me with this? Thanks in advance!

Hi @nikhil-varma,

Welcome to the Auth0 Community!

Can you please post the entirety of your Action? Be sure to omit sensitive data like secrets, emails etc.

@dan.woda I am not sure how, but I tried testing it again today and it looks like it is working. I have not changed the code at all in the action and this wasn’t the case 2-3 days back. Any idea why this could have such different states? I literally did not change the code. I just had just this code

exports.onExecutePreUserRegistration = async (event, api) => {
  if (event.request.geoip.continentCode === "NA") {

    // localize the error message 
    const LOCALIZED_MESSAGES = {
      en: 'You are not allowed to register.',
      es: 'No tienes permitido registrarte.'
    };

    const userMessage = LOCALIZED_MESSAGES[event.request.language] || LOCALIZED_MESSAGES['en'];
    api.access.deny('no_signups_from_north_america', userMessage);
  }
};

It’s possible that you had not deployed the action.

I definitely did deploy it multiple times, waited assuming it takes time for the change to come into effect but still had the same result

It should go into effect as soon as it has been successfully deployed (you will see the notification). You can look at your logs and see what was done previously vs. now, that may help clarify.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.