From 47712d815b621f230c6879e69c8276a661b60d0d Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Tue, 14 Nov 2023 11:45:09 +0100 Subject: [PATCH] Bugfix for userRole deletion --- client/src/locale/en.js | 3 ++- client/src/locale/nl.js | 5 +++-- server/src/main/java/access/api/UserRoleController.java | 3 +-- server/src/main/java/access/model/Authority.java | 9 --------- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/client/src/locale/en.js b/client/src/locale/en.js index 8e0b67ed..96db803a 100644 --- a/client/src/locale/en.js +++ b/client/src/locale/en.js @@ -315,7 +315,8 @@ const en = { removeInvitation: "Delete all selected invitations", resendInvitation: "Resend all selected invitations", inviter: "Send invitations to persons who will - once accepted - become guest users for the application", - overrideSettingsAllowed: "If checked then invitations for this role can't override the advanced setting (e.g. Email equality, eduID only and the role expiry end date)" + overrideSettingsAllowed: "If checked then invitations for this role can't override the advanced setting (e.g. Email equality, eduID only and the role expiry end date)", + removeUserRole: "Remove the selected user roles" }, confirmationDialog: { title: "Confirm", diff --git a/client/src/locale/nl.js b/client/src/locale/nl.js index 2370ace1..a5ff10d2 100644 --- a/client/src/locale/nl.js +++ b/client/src/locale/nl.js @@ -314,8 +314,9 @@ const nl = { inviteesTooltip: "Geef e-mailadressen op, gescheiden door komma, spaties of puntkomma, of een voor een met gebruik van de enter-toets. Je kunt ook een csv-bestand plakken met daarin op elke regel een e-mailadres.", removeInvitation: "Verwijder al de geselecteerde uitnodigingen", resendInvitation: "Stuur al de geselecteerde uitnodigingen opnieuw", - inviter: "Send invitations to persons who will - once accepted - become guest users for the application", - overrideSettingsAllowed: "If checked then invitations for this role can't override the advanced setting (e.g. Email equality, eduID only and the role expiry end date)" + inviter: "Verstuur uitnodigingen naar gebruikers die - als ze accepteren - gast gebruikers worden voor de applicatie", + overrideSettingsAllowed: "Indien ingeschakeld dan kunnen uitnodigingen voor de deze rol niet de geadvanceerde instellen (e.g. e-mail gelijkheid, alleen accepteren met eduID en de verloop- en eind-datum)", + removeUserRole: "Verwijder al de geselecteerde rollen" }, confirmationDialog: { title: "Bevestig", diff --git a/server/src/main/java/access/api/UserRoleController.java b/server/src/main/java/access/api/UserRoleController.java index 2cc95ee5..2c4bb2d3 100644 --- a/server/src/main/java/access/api/UserRoleController.java +++ b/server/src/main/java/access/api/UserRoleController.java @@ -73,8 +73,7 @@ public ResponseEntity> updateUserRoleExpirationDate(@Valida public ResponseEntity deleteUserRole(@PathVariable("id") Long id, @Parameter(hidden = true) User user) { LOG.debug("/deleteUserRole"); UserRole userRole = userRoleRepository.findById(id).orElseThrow(NotFoundException::new); - Authority requiredAuthority = userRole.getAuthority().nextAuthorityInHierarchy(); - UserPermissions.assertValidInvitation(user, requiredAuthority, List.of(userRole.getRole())); + UserPermissions.assertValidInvitation(user, userRole.getAuthority(), List.of(userRole.getRole())); userRoleRepository.delete(userRole); AccessLogger.userRole(LOG, Event.Deleted, user, userRole); return Results.deleteResult(); diff --git a/server/src/main/java/access/model/Authority.java b/server/src/main/java/access/model/Authority.java index 99fcd8d8..ba8b8900 100644 --- a/server/src/main/java/access/model/Authority.java +++ b/server/src/main/java/access/model/Authority.java @@ -28,15 +28,6 @@ public boolean hasHigherRights(Authority requiredAuthority) { return rights > requiredAuthority.rights; } - public Authority nextAuthorityInHierarchy() { - return switch (this.rights) { - case 0 -> INVITER; - case 1 -> MANAGER; - case 2 -> INSTITUTION_ADMIN; - default -> SUPER_USER; - }; - } - public String translate(String lang) { return translations.get(this.name()).get(lang); }