Mendelu/Prevent an admin from deleting their own account - #1446
Merged
milanmajchrak merged 3 commits intoAug 14, 2026
Conversation
Backport of the UFAL self-delete guard from dtq-dev (dspace-angular #1335, #1357, #1373) to this customer branch. The EPeople registry and the EPerson form now hide/disable the delete action for the currently authenticated user (with an explanatory tooltip), show a contextual warning in the confirmation modal when the target is a submitter and/or an administrator, and surface a friendly notification when the backend rejects a self-delete. Shared logic lives in the new EPersonDeleteGuardService so both call sites stay in sync. Refs dataquest-dev/dspace-customers#855
added 2 commits
August 11, 2026 09:46
The error branch of the EPeople registry delete handler was reusing
'notification.deleted.success', so any non-self-delete failure showed a
red toast reading "Successfully deleted EPerson" with an empty name.
Switch to 'notification.deleted.failure' and pass restResponse, which
the failure string interpolates as {{restResponse.errorMessage}}. This
matches what dtq-dev already does (07957d8) — the hunk was missed
when the change was translated to the 9.x component. Raised by Copilot
review on PR #1447.
Refs dataquest-dev/dspace-customers#855
Rewrites the four Czech strings for the self-delete guard so they read
naturally rather than as literal translations, keeping the repository's
established Czech terminology (uživatel / správce / záznamy / smazat) and
active phrasing ("Jeho smazáním odeberete…" instead of the nominal
"Smazání tohoto uživatele odebere…"). Wording is identical across all
customer branches. Raised in review on PR #1447.
Refs dataquest-dev/dspace-customers#855
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of the UFAL self-delete guard from
dtq-devontocustomer/mendelu— #1335 (the feature), #1357 (friendly rejection notification) and #1373 (tooltip clipped by the table).What changes
warningLabelinput onConfirmationModalComponent.EPersonDeleteGuardServiceso the registry and the form stay in sync.Branch-specific notes
Translated (not cherry-picked): DSpace 9.1 uses standalone components and
@ifcontrol flow, so there is noAccessControlModuleto register the service in —EPersonDeleteGuardServiceisprovidedIn: 'root'here, andNgbTooltipModule+BtnDisabledDirectivewere added to the two components'imports.Verified locally (Node 22):
ng test --include='src/app/access-control/epeople-registry/**/*.spec.ts'and--include='src/app/shared/confirmation-modal/**/*.spec.ts'all green;eslinton the changed files reports 0 errors.Backend counterpart: dataquest-dev/DSpace#1401 — the two must ship together.
Refs dataquest-dev/dspace-customers#855
How this was verified
Manual — on a live instance (JCU 9.3 pair)
Throwaway stack: backend built from the paired branch
jcu/be-forbid-admin-self-delete(REST on :8091,own DB / Solr), frontend served from the branch under test, logged in as an administrator.
204and the account was gone (404) — the bug in issue #855, reproduced.container="body"part of #1373).Automated
Locally on this branch (Node 22):
ng test --include='src/app/access-control/epeople-registry/**/*.spec.ts'→ 43 tests, 0 failures;--include='src/app/shared/confirmation-modal/**/*.spec.ts'→ 11 tests, 0 failures;eslinton the changed files → 0 errors.The CI
testsjob runs lint plus the full unit suite on this PR.The live run was on JCU 9.3 (DSpace 9.3). Mendelu (9.1) shares
eperson-delete-guard.service.tsand both templates byte-identically with the exercised branch; only the two*.component.tsfiles differ, and only where the branch bases already differed (Angular 18 vs 20). Not exercised live.Follow-up after Copilot review
Copilot flagged that the
elsebranch of the registry delete handler passednotification.deleted.successtonotificationsService.error(...), so any deletefailure other than a self-delete rendered a red toast reading "Successfully deleted
EPerson: """ — with an empty name, and with
{{restResponse.errorMessage}}neverfilled in.
Valid finding, and not a new idea: dtq-dev already fixes this in the very commit this
PR backports (
07957d83b1, UFAL port of dspace-angular#1335). The hunk was missed whenthe change was translated to the 9.x component. Fixed in a follow-up commit — the branch
now matches dtq-dev:
Only the two 9.x branches (
mendelu,jcu) needed this — the 7.6.1/7.6.5 branches tookthe hunk whole during the cherry-pick and already used the failure key, and TUL (7.5)
never used the key at all (it builds the message inline). Unit tests re-run after the
change and still green.
Live UI screenshots
Captured live in a browser (9.1 FE against a DSpace 9.3 backend): logged in as an administrator, opened
Access Control → EPeople. The admin's own row is the first one.
Before — the own row's Delete button is enabled/clickable (the bug).

After — the own row's Delete button is disabled and shows the tooltip "You cannot delete your own EPerson account."; other rows stay enabled.
