From 6592d3994721e1b17d78938f98ce0cacefe606ae Mon Sep 17 00:00:00 2001 From: Matus Kasak Date: Mon, 10 Aug 2026 13:12:03 +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 | 25 ++- .../epeople-registry.component.spec.ts | 189 +++++++++++++++++- .../epeople-registry.component.ts | 63 ++++-- .../eperson-delete-guard.service.spec.ts | 147 ++++++++++++++ .../eperson-delete-guard.service.ts | 145 ++++++++++++++ .../eperson-form/eperson-form.component.html | 19 +- .../eperson-form.component.spec.ts | 166 ++++++++++++++- .../eperson-form/eperson-form.component.ts | 98 ++++++--- .../confirmation-modal.component.html | 1 + .../confirmation-modal.component.spec.ts | 13 ++ .../confirmation-modal.component.ts | 1 + src/assets/i18n/cs.json5 | 12 ++ src/assets/i18n/en.json5 | 8 + 14 files changed, 824 insertions(+), 65 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 3dc4b6cedc7..fa9c57b2b70 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'; @@ -57,6 +58,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 4979f858193..2f6b17938ff 100644 --- a/src/app/access-control/epeople-registry/epeople-registry.component.html +++ b/src/app/access-control/epeople-registry/epeople-registry.component.html @@ -73,11 +73,26 @@