From 46e1d90dcb357df796ab8ebbbc16ce5fedead04b Mon Sep 17 00:00:00 2001 From: Matus Kasak Date: Mon, 10 Aug 2026 13:12:02 +0200 Subject: [PATCH 1/2] Prevent an admin from deleting their own account 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 --- .../access-control/access-control.module.ts | 2 + .../epeople-registry.component.html | 26 +++- .../epeople-registry.component.spec.ts | 31 ++++ .../epeople-registry.component.ts | 50 ++++-- .../eperson-delete-guard.service.spec.ts | 147 ++++++++++++++++++ .../eperson-delete-guard.service.ts | 145 +++++++++++++++++ .../eperson-form/eperson-form.component.html | 18 ++- .../eperson-form.component.spec.ts | 33 +++- .../eperson-form/eperson-form.component.ts | 54 +++++-- .../confirmation-modal.component.html | 1 + .../confirmation-modal.component.ts | 1 + src/app/shared/testing/auth-service.stub.ts | 4 + src/assets/i18n/cs.json5 | 12 ++ src/assets/i18n/en.json5 | 8 + 14 files changed, 497 insertions(+), 35 deletions(-) create mode 100644 src/app/access-control/epeople-registry/eperson-delete-guard.service.spec.ts create mode 100644 src/app/access-control/epeople-registry/eperson-delete-guard.service.ts diff --git a/src/app/access-control/access-control.module.ts b/src/app/access-control/access-control.module.ts index 47a971a882a..3eaff9e31dd 100644 --- a/src/app/access-control/access-control.module.ts +++ b/src/app/access-control/access-control.module.ts @@ -5,6 +5,7 @@ import { SharedModule } from '../shared/shared.module'; import { AccessControlRoutingModule } from './access-control-routing.module'; import { EPeopleRegistryComponent } from './epeople-registry/epeople-registry.component'; import { EPersonFormComponent } from './epeople-registry/eperson-form/eperson-form.component'; +import { EPersonDeleteGuardService } from './epeople-registry/eperson-delete-guard.service'; import { GroupFormComponent } from './group-registry/group-form/group-form.component'; import { MembersListComponent } from './group-registry/group-form/members-list/members-list.component'; import { SubgroupsListComponent } from './group-registry/group-form/subgroup-list/subgroups-list.component'; @@ -45,6 +46,7 @@ export const ValidateEmailErrorStateMatcher: DynamicErrorMessagesMatcher = provide: DYNAMIC_ERROR_MESSAGES_MATCHER, useValue: ValidateEmailErrorStateMatcher }, + EPersonDeleteGuardService, ] }) /** diff --git a/src/app/access-control/epeople-registry/epeople-registry.component.html b/src/app/access-control/epeople-registry/epeople-registry.component.html index 2d87f21d260..7a9826ca0e4 100644 --- a/src/app/access-control/epeople-registry/epeople-registry.component.html +++ b/src/app/access-control/epeople-registry/epeople-registry.component.html @@ -77,11 +77,27 @@