# Redirect user back to login after access deny

**URL:** <https://community.auth0.com/t/redirect-user-back-to-login-after-access-deny/78918>\
**Category:** Get Help\
**Created:** [February 25, 2022, 1:30pm UTC](https://community.auth0.com/t/redirect-user-back-to-login-after-access-deny/78918 "2022-02-25T13:30:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![imad](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/imad/32/34807_2.png) [@imad](https://community.auth0.com/u/imad)\
**Post date:** [February 25, 2022, 1:30pm UTC](https://community.auth0.com/t/redirect-user-back-to-login-after-access-deny/78918/1 "2022-02-25T13:30:51Z")

</div>

Hello,

I’ve implemented a login action to deny user if role is not admin:

```
if ((event.client.name === "Application Name") && !userRoles.includes("admin"))
    api.access.deny(`Access to ${event.client.name} is not allowed.`);

```

This works fine and message is displayed on callback. However, if I try to go back to the login screen, I am forced back to the callback (/api/auth/callback?error=access\_denied&error\_description=). I never see the login page. How do I force the user back to login page to login?

Thanks,  
IJ

---

<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:** [February 25, 2022, 7:22pm UTC](https://community.auth0.com/t/redirect-user-back-to-login-after-access-deny/78918/3 "2022-02-25T19:22:41Z")

</div>

Hey @imad !

You might want to look into using the `api.redirect.sendUserTo()` function as outlined [here](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/redirect-with-actions#start-a-redirect).

Let us know if that does the trick!

---

<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:** [March 28, 2022, 3:00pm UTC](https://community.auth0.com/t/redirect-user-back-to-login-after-access-deny/78918/4 "2022-03-28T15:00:54Z")

</div>

This topic was automatically closed after 10 days. New replies are no longer allowed.
