# Api.access.deny with pre-user-registration trigger

**URL:** <https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475>\
**Category:** Get Help\
**Tags:** signup-prompt-new-experience, login-experience\
**Created:** [February 20, 2025, 8:01am UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475 "2025-02-20T08:01:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve227](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@steve227](https://community.auth0.com/u/steve227)\
**Post date:** [February 20, 2025, 8:01am UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/1 "2025-02-20T08:01:32Z")

</div>

I added a trigger on pre-user-registration to deny registration for one application while still allowing it for others.

```auto
exports.onExecutePreUserRegistration = async (event, api) => {
  // deny signups on staging
  
  if (event.client?.client_id === '(redacted)') {
    api.validation.error('denied', 'Not allowed');
    api.access.deny('signup_denied', 'Signup not allowed');
  }
};

```

It does half of what I expected, and that is to block registration. The other half would be to show a message to the user. As you can see, I tried api.access.deny and api.validation.error. Neither one shows anything on the Universal Login form. Where might I have gone wrong here?

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [February 20, 2025, 5:21pm UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/3 "2025-02-20T17:21:44Z")

</div>

Hi @steve227,

Welcome to the Auth0 Community!

I have replicated the issue and tested the code you’ve provided.

The `api.validation.error()` method will display a message above the email input field to warn you that the credentials have not been validated.

 ![Screenshot 2025-02-20 at 18.20.03](https://global.discourse-cdn.com/auth0/original/3X/0/2/02d1a65fb7a2f14c3df3583d70f3bf7c08bf0b3f.png)

 ![Screenshot 2025-02-20 at 18.21.37](https://global.discourse-cdn.com/auth0/original/3X/0/e/0ead7888f46a6e0ce2591b87c7aae547f40888a5.png)

The `api.access.deny()` method will display the message on the password input field as if the password inputed is wrong.

 ![Screenshot 2025-02-20 at 18.22.29](https://global.discourse-cdn.com/auth0/original/3X/3/1/3108c15e84f51cb88887d7be42e39209bd37d0ef.png)

 ![Screenshot 2025-02-20 at 18.22.43](https://global.discourse-cdn.com/auth0/original/3X/4/5/45d32a4c89140ddec3cf28ae12cd545386d1a337.png)

The reason it’s only doing half of what is expected of it is that the moment you call either function, the code execution stops. Only the first one will be executed.

 ![Screenshot 2025-02-20 at 18.23.23](https://global.discourse-cdn.com/auth0/original/3X/7/c/7cd7a2a40a8866610beae870c0ad29d1bfdf71f2.png)

 ![Screenshot 2025-02-20 at 18.23.30](https://global.discourse-cdn.com/auth0/original/3X/5/7/57e112d1e2cc6256a4fbd61e585a0f895b96d034.png)

As for why it’s not showing any message on the Universal Login form, make sure no settings that would trigger the Classic Login Experience are turned on, such as Customize Login Page.

If you have any other questions feel free to ask.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![steve227](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@steve227](https://community.auth0.com/u/steve227)\
**Post date:** [February 21, 2025, 12:40am UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/4 "2025-02-21T00:40:23Z")

</div>

Thanks for the quick reply. And thank you for the clarification that only one of the two messages can be used. As far as not showing any message, how can I be sure I haven’t made any changes that would trigger the Classic Login Experience. I can’t easily identify the difference between Classic and Universal. Does the following screenshot look like Universal?

 ![image](https://global.discourse-cdn.com/auth0/original/3X/e/0/e0408769aae9836e1553c2ed8112ea3c27cbe8b0.png)

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [February 21, 2025, 1:19pm UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/5 "2025-02-21T13:19:44Z")

</div>

If you go to your dashboard \> Branding \> Universal Login \> Advanced options you should have Universal Login selected. All the other tabs need to have their customizability option turned off.

 ![Screenshot 2025-02-21 at 14.46.39](https://global.discourse-cdn.com/auth0/original/3X/6/d/6d01c7b427e6669ce35107a7475cb66342dc0400.png)

If at least one of them is turned on the Classic Login Experience will be used instead.

If you have any customization that you might have applied there, you can use the tools the Universal Login Experience has to recreate them.

---

<div class="post-metadata">

**Author:** ![steve227](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@steve227](https://community.auth0.com/u/steve227)\
**Post date:** [February 24, 2025, 3:42am UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/6 "2025-02-24T03:42:10Z")

</div>

I checked through those settings. I do not have any customizations enabled. In any case, it is showing the error message now. Maybe there was a delay because of browser caching that caused it to not work for a long while.

---

<div class="post-metadata">

**Author:** ![steve227](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@steve227](https://community.auth0.com/u/steve227)\
**Post date:** [February 24, 2025, 8:33am UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/7 "2025-02-24T08:33:38Z")

</div>

Well this is interesting. It stopped working again.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/d/8/d88a1ab3728441c255626928a1e8c895be8ee490.png)

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [February 24, 2025, 2:07pm UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/8 "2025-02-24T14:07:36Z")

</div>

Is this happening after you put in a valid password and proceed?

---

<div class="post-metadata">

**Author:** ![steve227](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@steve227](https://community.auth0.com/u/steve227)\
**Post date:** [February 24, 2025, 2:17pm UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/9 "2025-02-24T14:17:12Z")

</div>

Well, maybe not. I guess I was too quick to assume the issue was with the hook code. I’ve become so accustomed to generating passwords with 1Password and not manually, that I never pay attention to the “Your password must contain” section. Sorry to trouble you.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 10, 2025, 2:17pm UTC](https://community.auth0.com/t/api-access-deny-with-pre-user-registration-trigger/182475/10 "2025-03-10T14:17:33Z")

</div>

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