# Logout if access deny

**URL:** <https://community.auth0.com/t/logout-if-access-deny/128312>\
**Category:** Get Help\
**Tags:** identifier-first, login-experience\
**Created:** [February 26, 2024, 10:28am UTC](https://community.auth0.com/t/logout-if-access-deny/128312 "2024-02-26T10:28:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![toshuk.kr](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/toshuk.kr/32/49494_2.png) [@toshuk.kr](https://community.auth0.com/u/toshuk.kr)\
**Post date:** [February 26, 2024, 10:28am UTC](https://community.auth0.com/t/logout-if-access-deny/128312/1 "2024-02-26T10:28:57Z")

</div>

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (!event.user.email.endsWith("@mycomp.com")) {
    api.access.deny(`Access to ${event.client.name} is not allowed.`);
  }
};

```

how can i logout user if access deny ?

---

<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 26, 2024, 9:14pm UTC](https://community.auth0.com/t/logout-if-access-deny/128312/3 "2024-02-26T21:14:41Z")

</div>

Hey there @toshuk.kr !

The action shared should result in a failed login - Can you elaborate on what you are looking to achieve here if the user isn’t able to login to begin with?

---

<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, 9:14pm UTC](https://community.auth0.com/t/logout-if-access-deny/128312/4 "2024-03-11T21:14:52Z")

</div>

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