Skip to content

Commit

Permalink
Bugfix for userRole deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Nov 14, 2023
1 parent 397577a commit 47712d8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
3 changes: 2 additions & 1 deletion client/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions client/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions server/src/main/java/access/api/UserRoleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ public ResponseEntity<Map<String, Integer>> updateUserRoleExpirationDate(@Valida
public ResponseEntity<Void> 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();
Expand Down
9 changes: 0 additions & 9 deletions server/src/main/java/access/model/Authority.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 47712d8

Please sign in to comment.