# How to take specific action when authorization is denied in a Pre User Registration Auth0 custom Action

**URL:** <https://community.auth0.com/t/how-to-take-specific-action-when-authorization-is-denied-in-a-pre-user-registration-auth0-custom-action/138744>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [July 12, 2024, 5:12pm UTC](https://community.auth0.com/t/how-to-take-specific-action-when-authorization-is-denied-in-a-pre-user-registration-auth0-custom-action/138744 "2024-07-12T17:12:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephenrs](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@stephenrs](https://community.auth0.com/u/stephenrs)\
**Post date:** [July 12, 2024, 5:12pm UTC](https://community.auth0.com/t/how-to-take-specific-action-when-authorization-is-denied-in-a-pre-user-registration-auth0-custom-action/138744/1 "2024-07-12T17:12:35Z")

</div>

I’m using Auth0 Lock for logins/registrations and I’ve implemented a Pre User Registration custom Action to perform additional verification on users before allowing access. Everything is working fine, and I’m passing a “reason” and a “message” to the call to api.access.deny(), which can be different depending on which problems are detected in the Action. I can see the “reasons” displayed in the Auth0 monitoring log.

I would like to take different actions on our end, such as redirecting to specific pages, depending on the “reason” a user has been denied access. However, I haven’t found a way to access the “reason” after the access denial occurs.

I’ve tried listening for lock-\>authorization\_error and lock-\>unrecoverable\_error but neither appear to be triggered. So far, the only way that I’ve found to even know that the access denial has occurred is because the lock.fallback error is displayed. So I could modify the error message to handle this case, but obviously this is far from ideal.

So, how can I find out the “reason” a user has been denied access from a Pre User Registration custom Action?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [August 5, 2024, 9:45pm UTC](https://community.auth0.com/t/how-to-take-specific-action-when-authorization-is-denied-in-a-pre-user-registration-auth0-custom-action/138744/3 "2024-08-05T21:45:42Z")

</div>

Hi @stephenrs,

Welcome to the Auth0 Community!

> [@stephenrs](#):
>
> I would like to take different actions on our end, such as redirecting to specific pages, depending on the “reason” a user has been denied access. However, I haven’t found a way to access the “reason” after the access denial occurs.

Yes, this happens because the `api.access.deny()` method stops the sign up process immediately and prevents any further actions from being executed. (Reference: [Actions Triggers: pre-user-registration - API Object](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow/api-object#:~:text=Deny%20the%20user%20from%20being%20able%20to%20register.%20The%20signup%20flow%20will%20immediately%20stop%20following%20the%20completion%20of%20this%20action%20and%20no%20further%20Actions%20will%20be%20executed.))

It’s also important to note that a pre-user registration action will not allow you to redirect users to external pages. Only a post-login action can redirect users.

If you need to redirect your users based on certain conditions after they sign up, you should use a post-login action instead.

> [@stephenrs](#):
>
> So, how can I find out the “reason” a user has been denied access from a Pre User Registration custom Action?

You can find out the reason a user has been denied access by checking your logs.

Let me know if you have any questions.

Thanks,  
Rueben

---

<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:** [August 19, 2024, 9:45pm UTC](https://community.auth0.com/t/how-to-take-specific-action-when-authorization-is-denied-in-a-pre-user-registration-auth0-custom-action/138744/4 "2024-08-19T21:45:59Z")

</div>

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