ZHAW-PM4-Compass / compass

A time-, mood- and incident tracking application for Stadtmuur called Compass 🧭
https://stadtmuur.ch/
MIT License
0 stars 0 forks source link

Add Backend check for User Role on confirmed/day notes/ etc. endpoints #143

Closed x-snackage-x closed 3 weeks ago

x-snackage-x commented 1 month ago

The following three endpoints have to be protected against access through a participant:

An example of how to do it for an ADMIN:

String callerId = authentication.getName();
UserRole callingRole = userService.getUserRole(callerId);
if (callingRole != UserRole.ADMIN) {
    return new ResponseEntity<>(HttpStatus.FORBIDDEN);
}

These will also require some tests for coverage.