Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Avoid last admin deactivate itself #22949

Merged
merged 17 commits into from
Oct 18, 2021
Merged

Conversation

ostjen
Copy link
Contributor

@ostjen ostjen commented Aug 17, 2021

Proposed changes (including videos or screenshots)

Co-authored-by: @Kartik18g

Issue(s)

Steps to test or reproduce

Further comments

@ostjen ostjen changed the title [FIX] Avoid /last admin deactivate itself [FIX] Avoid last admin deactivate itself Aug 17, 2021
@ostjen ostjen requested a review from KevLehman August 17, 2021 12:58
@lgtm-com
Copy link

lgtm-com bot commented Aug 18, 2021

This pull request introduces 1 alert when merging 60ae3e9 into e764914 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types

server/methods/setUserActiveStatus.js Outdated Show resolved Hide resolved
server/methods/setUserActiveStatus.js Outdated Show resolved Hide resolved
@@ -39,6 +39,15 @@ export function setUserActiveStatus(userId, active, confirmRelinquish = false) {
return false;
}

const userAdmin = Users.findOneAdmin(userId.count);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be called if you're actually trying to disable the user, like inside the following if statement

Co-authored-by: Matheus Barbosa Silva <36537004+matheusbsilva137@users.noreply.github.com>
@ostjen ostjen dismissed KevLehman’s stale review October 18, 2021 16:27

matheus reviewed

@ostjen ostjen merged commit 65cc04e into develop Oct 18, 2021
@ostjen ostjen deleted the lastAdminDeactivateItself branch October 18, 2021 16:27
@sampaiodiego sampaiodiego mentioned this pull request Oct 28, 2021
method: 'removeUserFromRole',
action: 'Remove_last_admin',
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add this check to removing role if role is admin. Some people seem to keep removing the last admin. 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants