Adding custom login error

We are currently using Actions to check certain conditions and block a user from signing in.

For example
exports.onExecutePostLogin = async (event, api) => {

if (conditionIsTrue) {
          return api.access.deny('error_code', `Error message we want to show.`);
        }

However, this is redirecting back to our application with the error and error message in the GET parameters, but now pausing the login flow and showing an error, similar to the invalid password error.

Is there a way of adding an error on the login page instead of doing a redirect?

Hi @jgarrett,

Welcome to the Auth0 Community!

Unfortunately, when using the api.access.deny() method in a Post-Login Action, it will send your user back to your callback URL with the error you defined in the script.

There won’t be a way to add the error directly on the login page conditionally based on some criteria.

If needed, you could refer to our Customize Error Pages documentation on how to display a custom error page.

Let me know if you have any additional questions.

Thanks,
Rueben

How would I just display an error?

Hi @jgarrett,

Unfortunately, there is no out-of-the-box solution to add and display an error on the login page instead of doing a redirect.

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