Skip to content

Commit bcdcf52

Browse files
author
Matus Kasak
committed
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
1 parent 6ce85de commit bcdcf52

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

src/app/access-control/epeople-registry/epeople-registry.component.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,8 @@ describe('EPeopleRegistryComponent', () => {
283283
const deleteButtons = fixture.debugElement.queryAll(By.css('.access-control-deleteEPersonButton'));
284284

285285
expect(deleteButtons.length).toBe(2);
286-
expect(deleteButtons[0].nativeElement.getAttribute('aria-disabled')).toBeNull();
287-
expect(deleteButtons[1].nativeElement.getAttribute('aria-disabled')).toBe('true');
288-
expect(deleteButtons[1].nativeElement.classList.contains('disabled')).toBeTrue();
286+
expect(deleteButtons[0].nativeElement.disabled).toBeFalse();
287+
expect(deleteButtons[1].nativeElement.disabled).toBeTrue();
289288
});
290289

291290
it('should call submitter checks and compose the combined warning label', fakeAsync(() => {

src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model
3737
import { ActivatedRoute, Router } from '@angular/router';
3838
import { RouterStub } from '../../../shared/testing/router.stub';
3939
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
40-
import { RouterTestingModule } from '@angular/router/testing';
4140
import { WorkspaceitemDataService } from '../../../core/submission/workspaceitem-data.service';
4241
import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service';
4342
import { SearchService } from '../../../core/shared/search/search.service';
@@ -664,8 +663,7 @@ describe('EPersonFormComponent', () => {
664663
it('should render the delete button as disabled for the current user', () => {
665664
const deleteButton = fixture.debugElement.query(By.css('.delete-button'));
666665
expect(deleteButton).not.toBeNull();
667-
expect(deleteButton.nativeElement.getAttribute('aria-disabled')).toBe('true');
668-
expect(deleteButton.nativeElement.classList.contains('disabled')).toBeTrue();
666+
expect(deleteButton.nativeElement.disabled).toBeTrue();
669667
});
670668
});
671669

0 commit comments

Comments
 (0)