# Custom Action: user stays logged into Auth0 after api.access.deny

**URL:** <https://community.auth0.com/t/custom-action-user-stays-logged-into-auth0-after-api-access-deny/145425>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [September 5, 2024, 8:37pm UTC](https://community.auth0.com/t/custom-action-user-stays-logged-into-auth0-after-api-access-deny/145425 "2024-09-05T20:37:51Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 5, 2024, 11:12pm UTC](https://community.auth0.com/t/custom-action-user-stays-logged-into-auth0-after-api-access-deny/145425/3 "2024-09-05T23:12:53Z")

</div>

Hey there @mcantrell !

> [@mcantrell](#):
>
> Is there a way to prevent the login so this condition doesn’t occur?

As `api.access.deny` does not end any existing session, you’ll also want to log users out in order to avoid the loop you’re experiencing. Please see the following post:

> [@How to handle access denied response](https://community.auth0.com/t/how-to-handle-access-denied-response/136668/3):
>
> Hi @gabor.ottlik.hun, When you use the api.access.deny() method, it will deny users from logging in, but their session will remain intact. So, in subsequent login attempts, the user will continuously be sent to the error page (http://localhost:3000/api/auth/callback?error=access\_denied&error\_description=access%20denied.&state=eyJyZXR1cm5UbyI6Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9) until the user logs out. That said, you will need to log the user out whenever they have been denied access to kill the …

---

_[View the full topic](https://community.auth0.com/t/custom-action-user-stays-logged-into-auth0-after-api-access-deny/145425)._
