diff --git a/src/controllers/GroupsController.ts b/src/controllers/GroupsController.ts index e0e4425..36446f9 100644 --- a/src/controllers/GroupsController.ts +++ b/src/controllers/GroupsController.ts @@ -414,9 +414,7 @@ export class GroupsController { h.error(404, "Membership not found!"); // If the user is an admin, he must not be the last admin of the group - // TODO : use new method - if(userID == h.getUserId() && currUserMembership.level == GroupMembershipLevels.ADMINISTRATOR - && await GroupsHelper.CountMembersAtLevel(groupID, GroupMembershipLevels.ADMINISTRATOR) == 1) + if(userID == h.getUserId() && await GroupsHelper.IsLastAdmin(groupID, userID)) h.error(401, "You are the last administrator of this group!");