# Adding custom login error

**URL:** <https://community.auth0.com/t/adding-custom-login-error/128008>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [February 21, 2024, 9:38pm UTC](https://community.auth0.com/t/adding-custom-login-error/128008 "2024-02-21T21:38:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgarrett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jgarrett/32/49290_2.png) [@jgarrett](https://community.auth0.com/u/jgarrett)\
**Post date:** [February 21, 2024, 9:38pm UTC](https://community.auth0.com/t/adding-custom-login-error/128008/1 "2024-02-21T21:38:09Z")

</div>

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

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

```auto
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?

---

<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:** [February 23, 2024, 1:26am UTC](https://community.auth0.com/t/adding-custom-login-error/128008/3 "2024-02-23T01:26:40Z")

</div>

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](https://auth0.com/docs/customize/universal-login-pages/custom-error-pages) documentation on how to display a custom error page.

Let me know if you have any additional questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![jgarrett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jgarrett/32/49290_2.png) [@jgarrett](https://community.auth0.com/u/jgarrett)\
**Post date:** [February 23, 2024, 1:39am UTC](https://community.auth0.com/t/adding-custom-login-error/128008/4 "2024-02-23T01:39:09Z")

</div>

How would I just display an error?

---

<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:** [February 26, 2024, 6:26pm UTC](https://community.auth0.com/t/adding-custom-login-error/128008/5 "2024-02-26T18:26:16Z")

</div>

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.

---

<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 11, 2024, 6:26pm UTC](https://community.auth0.com/t/adding-custom-login-error/128008/6 "2024-03-11T18:26:18Z")

</div>

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