# UnauthorizedError in rule still redirects

**URL:** <https://community.auth0.com/t/unauthorizederror-in-rule-still-redirects/60827>\
**Category:** Get Help\
**Created:** [April 9, 2021, 10:05am UTC](https://community.auth0.com/t/unauthorizederror-in-rule-still-redirects/60827 "2021-04-09T10:05:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian.borresen](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/christian.borresen/32/12821_2.png) [@christian.borresen](https://community.auth0.com/u/christian.borresen)\
**Post date:** [April 9, 2021, 10:05am UTC](https://community.auth0.com/t/unauthorizederror-in-rule-still-redirects/60827/1 "2021-04-09T10:05:46Z")

</div>

Hi,

I appreciate any help I can get. I’ve set up auth0 in our login flow and the “happy path” works just fine. However, I’ve also set up a rule that upon login does a call to our API and perform some permission checks. If the user doesn’t have the right permissions, I’m doing `return callback(new UnauthorizedError('User unauthorized'));`. However, the user is still redirected to the redirectURI, with an error in the url. I would expect the user to not be redirected in the first place and rather get an error message similar to when they attempt to log in with the wrong username/password. Is that possible?

Thank you

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [April 9, 2021, 7:08pm UTC](https://community.auth0.com/t/unauthorizederror-in-rule-still-redirects/60827/3 "2021-04-09T19:08:00Z")

</div>

Hi @christian.borresen,

Welcome to the Community!

When an authorization error is thrown, the application must handle the error by using the error description in the URL. Unfortunately, you can’t display the error on the Universal Login page that is thrown in a rule since the rule runs after the user logs in.

Here is a detailed FAQ that explains more: [Can I show errors raised in rules in the login page?](https://community.auth0.com/t/can-i-show-errors-raised-in-rules-in-the-login-page/51143)

---

<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:** [April 24, 2021, 7:08pm UTC](https://community.auth0.com/t/unauthorizederror-in-rule-still-redirects/60827/4 "2021-04-24T19:08:35Z")

</div>

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