# User deactivation error

**URL:** <https://forums.rocket.chat/t/user-deactivation-error/12517>\
**Category:** Community Support\
**Created:** [November 1, 2021, 12:54pm UTC](https://forums.rocket.chat/t/user-deactivation-error/12517 "2021-11-01T12:54:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yures](https://avatars.discourse-cdn.com/v4/letter/y/db5fbb/32.png) [@yures](https://forums.rocket.chat/u/yures)\
**Post date:** [November 1, 2021, 12:54pm UTC](https://forums.rocket.chat/t/user-deactivation-error/12517/1 "2021-11-01T12:54:26Z")

</div>

### Description

Hi Folks. When I try to deactivate a user, I get an error message: “Leaving the app without an active admin is not allowed [error-action-not-allowed]”, but I have the admin role. It was OK on the last version 3. But now, after upgrading to 4.1.0, this happens. Is this a bug or something needs to be adjusted somewhere?

### Server Setup Information

- Version of Rocket.Chat Server: 4.1.0
- Operating System: Ubuntu 20.04
- Deployment Method: tar
- Number of Running Instances: 2
- DB Replicaset Oplog: yes
- NodeJS Version: 12.22.1
- MongoDB Version: 5.0
- Proxy: nginx
- Firewalls involved:

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [November 1, 2021, 2:24pm UTC](https://forums.rocket.chat/t/user-deactivation-error/12517/2 "2021-11-01T14:24:21Z")

</div>

Hi @Yures! Welcome to our forum.

I think this is probably something introduced at 4.1.0 according to here:

> **[Release 4.1.0 · RocketChat/Rocket.Chat](https://github.com/RocketChat/Rocket.Chat/releases/tag/4.1.0)**
>
> 2021-10-27 · 1 🎉 · 4 🚀 · 25 🐛 · 38 🔍 · 23 👩‍💻👨‍💻
> Engine versions
> 
> Node: 12.22.1
> NPM: 6.14.1
> MongoDB: 3.6, 4.0, 4.2, 4.4, 5.0
> Apps-Engine: 1.28.0
> 
> 🎉 New features
> 
> Stream to get individual ...

the release notes point to this PR here:

> <https://github.com/RocketChat/Rocket.Chat/pull/22949>
>
> \<!-- Your Pull Request name should start with one of the following tags
> \[NEW\]… For new features
> \[IMPROVE\] For an improvement (performance or little improvements) in existing features
> \[FIX\] For bug fixes that affect the end-user
> \[BREAK\] For pull requests including breaking changes
> Chore: For small tasks
> Doc: For documentation
> \--\>
> 
> \<!-- Checklist!!! If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code. 
> - I have read the Contributing Guide - https://github.com/RocketChat/Rocket.Chat/blob/develop/.github/CONTRIBUTING.md#contributing-to-rocketchat doc
> - I have signed the CLA - https://cla-assistant.io/RocketChat/Rocket.Chat
> - Lint and unit tests pass locally with my changes
> - I have added tests that prove my fix is effective or that my feature works (if applicable)
> - I have added necessary documentation (if applicable)
> - Any dependent changes have been merged and published in downstream modules
> \--\>
> 
> \## Proposed changes (including videos or screenshots)
> 
> \<!--
> Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
> If it fixes a bug or resolves a feature request, be sure to link to that issue below.
> This description will appear in the release notes if we accept the contribution.
> 
> \--\>
> Co-authored-by: @Kartik18g 
> 
> 
> \## Issue(s)
> 
> 
> \## Steps to test or reproduce
> 
> 
> \## Further comments

Please, can you:

- Reproduce this behavior on a clean new install?
- detail the exact steps and order to reproduce it?

We should triage this, and understand if it’s indeed a bug or an expected behavior.

If it’s a bug, we can open up an Issue at the github repo.

Thanks!

---

<div class="post-metadata">

**Author:** ![yures](https://avatars.discourse-cdn.com/v4/letter/y/db5fbb/32.png) [@yures](https://forums.rocket.chat/u/yures)\
**Post date:** [November 2, 2021, 7:50am UTC](https://forums.rocket.chat/t/user-deactivation-error/12517/3 "2021-11-02T07:50:01Z")

</div>

Made a clean installation. The versions are the same as in the working installation. The settings are all by default. Created a user and when I try to deactivate it, the same error. Also another error came up, when trying to change the password of the user in the admin panel, there is an error: “TOTP Required [totp-required]”.

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [November 3, 2021, 5:27pm UTC](https://forums.rocket.chat/t/user-deactivation-error/12517/4 "2021-11-03T17:27:20Z")

</div>

Hi Yures!

I was able to reproduce this error. It’s indeed a bug.

You can no longer deactivate any user because of this new check. The user I tried to deactivate is not even an admin.

This will happen if you only have one admin. If you create a second admin, it will work.

it probably needs to check if the user marked for deactivation is an admin.

I can confirm the same happens when trying to deactivate thru the REST API:

```auto
In [9]: t = rocket.users_set_active_status(user_id="L9GwYzGLotxnfgTp8", active_status=False)

In [10]: t
Out[10]: <Response [400]>

In [11]: t.json()
Out[11]: 
{'success': False,
 'error': 'Leaving the app without an active admin is not allowed [error-action-not-allowed]',
 'errorType': 'error-action-not-allowed',
 'details': {'method': 'removeUserFromRole', 'action': 'Remove_last_admin'}}

```

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [November 3, 2021, 6:12pm UTC](https://forums.rocket.chat/t/user-deactivation-error/12517/5 "2021-11-03T18:12:38Z")

</div>

Hey again! I just produced a PR to fix this:

> <https://github.com/RocketChat/Rocket.Chat/pull/23623>
>
> user admin check at setUserActiveStatus
> 
> \## Issue(s)
> \#23622
> 
> \## Steps to t…est or reproduce
> check issue #23622

Thanks!!
