Skip to content

fix: prevent admin users from being assigned to non-superadmin members#1509

Merged
bobcaprice merged 3 commits into
mainfrom
PD-5857_possible-to-create-admin-users-for-non-superadmin-enabled-members_Daniel-Palafox
Jul 8, 2026
Merged

fix: prevent admin users from being assigned to non-superadmin members#1509
bobcaprice merged 3 commits into
mainfrom
PD-5857_possible-to-create-admin-users-for-non-superadmin-enabled-members_Daniel-Palafox

Conversation

@DanielPalafox

Copy link
Copy Markdown
Member

fix: prevent admin users from being assigned to non-superadmin members

UI: reset isAdmin to false when the selected member is switched to one
that does not have superadminEnabled, so the stale value can never be
submitted silently (previously the checkbox was hidden but the form
control kept its true value).
Add a spec that asserts the reset behaviour.

Backend: add a service-layer guard in UserService that throws
BadRequestAlertException when isAdmin=true and the member has
superadminEnabled null or false. Applied in both createUser and
updateUser as defence-in-depth behind the existing UserValidator check.
Add tests for both code paths; correct an existing test that was
inadvertently setting isAdmin=true against a non-superadmin member.

Data fix: add demote_non_superadmin_admins.py (query-fixes) to identify
and correct any admin users already in the database that do not belong
to a superadmin-enabled member (plan → confirm → execute → verify,
--dry-run supported).

Relates to https://orcid.clickup.com/t/9014437828/PD-5857

@DanielPalafox
DanielPalafox requested a review from bobcaprice July 6, 2026 18:51
@DanielPalafox
DanielPalafox force-pushed the PD-5857_possible-to-create-admin-users-for-non-superadmin-enabled-members_Daniel-Palafox branch from 0a07aba to e306e3a Compare July 8, 2026 13:44
@bobcaprice
bobcaprice merged commit 761cf86 into main Jul 8, 2026
8 checks passed
@bobcaprice
bobcaprice deleted the PD-5857_possible-to-create-admin-users-for-non-superadmin-enabled-members_Daniel-Palafox branch July 8, 2026 13:58
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.

2 participants