# Cancel login from within a rule

**URL:** <https://community.auth0.com/t/cancel-login-from-within-a-rule/61609>\
**Category:** Get Help\
**Tags:** rules\
**Created:** [April 22, 2021, 8:00pm UTC](https://community.auth0.com/t/cancel-login-from-within-a-rule/61609 "2021-04-22T20:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yakir/32/26807_2.png) [@yakir](https://community.auth0.com/u/yakir)\
**Post date:** [April 22, 2021, 8:00pm UTC](https://community.auth0.com/t/cancel-login-from-within-a-rule/61609/1 "2021-04-22T20:00:00Z")

</div>

Hi

I’m using universal login.

I want within a rule to be able to make a decision that this user should not be logged in and fail his login.  
But currently if I just do:

return callback(new UnauthorizedError(“Failed”));

It does redirect to my server at /complete/auth0/

But I want it to just fail and stay on the auth0 login page, same as if the user has inputted a wrong password.

P.S - This is done in social-login using google

---

<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 23, 2021, 11:56am UTC](https://community.auth0.com/t/cancel-login-from-within-a-rule/61609/3 "2021-04-23T11:56:20Z")

</div>

Hi @yakir,

Unfortunately, rules run after authentication, and so redirecting back to the login page would go against the natural flow. When the `UnauthorizedError` is thrown in your rule, the user will be redirected to your app with the error message as a URL query string parameter.

Here is additional information from our FAQs:  
[https://community.auth0.com/t/can-i-show-errors-raised-in-rules-in-the-login-page/51143](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:** [May 8, 2021, 11:57am UTC](https://community.auth0.com/t/cancel-login-from-within-a-rule/61609/4 "2021-05-08T11:57:06Z")

</div>

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