Skip to content

Commit

Permalink
change getUserPermissions to return list of user permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Battlestad committed May 29, 2024
1 parent 2c6dc95 commit 14a0c4f
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ public Mono<ResponseEntity<AdminUser>> checkAdminUser(
}

@GetMapping("userpermissions")
public Mono<ResponseEntity<List<UserPermission>>> getUserPermissions(
public Mono<ResponseEntity<List<UserPermissionDto>>> getUserPermissions(
@AuthenticationPrincipal Mono<Authentication> authenticationMono
) {
return isAdmin(authenticationMono)
.flatMap(isAdmin -> {
if (isAdmin) {
return Mono.fromCallable(userPermissionRepository::findAll)
.subscribeOn(Schedulers.boundedElastic())
.map(userPermissions -> ResponseEntity.ok().body(userPermissions));
.map(userPermissions -> {
List<UserPermissionDto> userPermissionDtos = new java.util.ArrayList<>(List.of());
userPermissions.forEach(userPermission -> userPermissionDtos.add(buildUserPermissionDto(userPermission)));
return ResponseEntity.ok().body(userPermissionDtos);
});
} else {
return Mono.just(ResponseEntity.status(HttpStatus.FORBIDDEN).build());
}
Expand Down

0 comments on commit 14a0c4f

Please sign in to comment.