Redirect Users After Denying Registration

I’m looking for a way to redirect users back to an error page my organization hosts after preventing sign up/registration for a given user.

I’m preventing access in a Pre-User Registration Flow action using api.access.deny.

This is all well and good, but after this happens, we’d like to redirect them to an error page hosted on one of our domains/sites that can give them the reason why they failed to create an account and direct them as to how to proceed.

The problem there is the only place in the login flow I’ve found so far that allows to to redirect someone is in [onExecutePostLogin](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/redirect-with-actions#start-a-redirect). The documentation for onExecutePreUserRegistration states that when you use api.access.deny() “The signup flow will immediately stop following the completion of this action and no further Actions will be executed” - meaning no other actions will fire.

Is there something I’m missing here? Is there another way to do this?

Hi @e.stallcup,

Welcome to the Auth0 Community!

I understand you have questions about redirecting users after them denying registration.

Unfortunately, this is not possible with a Pre-User Registration Action, as you have observed.

For now, only the Post-Login Action allows for user redirection. In this scenario, there are a couple of options moving forward.

First, when using the Pre-User Registration, there is an option to specify the reason and user message in the api.access.deny(reason, userMessage) method, which could explain to the user why they were denied registration.

Or the second option is to use the Post-Login Action to deny the user access and then redirect them to your custom-hosted page. This is the approach I would recommend for your use case.

Understandably, this will prevent user login and increment the number of users in your database, which may warrant some degree of grooming. However, this will not affect your MAU (Monthly Active Users) count since these users never successfully “logged in”.

I hope this helps!

Please let me know how this works for you or if you have any additional questions.

Thanks,
Rueben

1 Like

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