Skip to content

fix: BE-23 - Prevent self-demotion of the last super-admin - #830

Merged
Qoder-Voidd merged 1 commit into
Akazajan:mainfrom
zainabbaba31-source:feature/be-23-last-super-admin-guard
Oct 23, 2026
Merged

Qoder-Voidd merged 1 commit into
Akazajan:mainfrom
zainabbaba31-source:feature/be-23-last-super-admin-guard

Conversation

@zainabbaba31-source

Copy link
Copy Markdown
Contributor

Summary

Guard administrative role changes against removing the final super-admin account.

Changes

  • backend/src/users/providers/users.service.ts - block role demotion of SUPER_ADMIN to non-SUPER_ADMIN when only one super-admin remains; also block membership status changes that would deactivate/suspend the last super-admin.
  • backend/src/users/providers/update-member-status.provider.ts - defensive guard preventing demotion/deactivation of the last super-admin at the provider level.

Acceptance

  • The final super-admin cannot be demoted or deactivated; safe changes remain available and are tested.

Closes #645

- Guard role demotion from SUPER_ADMIN to non-SUPER_ADMIN in UsersService.updateUser by counting super-admins and blocking when only one remains.
- Block membership status changes that would deactivate/suspend the last super-admin via UsersService.updateMemberStatus.
- Enforce the same guard directly in UpdateMemberStatusProvider as a defensive check.

Closes Akazajan#645

@Qoder-Voidd Qoder-Voidd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@Qoder-Voidd
Qoder-Voidd merged commit 4053931 into Akazajan:main Oct 23, 2026
1 of 7 checks passed
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.

BE-23 — Prevent self-demotion of the last super-admin

2 participants