Skip to content

Commit

Permalink
Merge pull request #864 from terrestris/fix-keycloak-group-extraction
Browse files Browse the repository at this point in the history
fix: prevent exception when keycloak group does not exist
  • Loading branch information
hwbllmnn authored May 21, 2024
2 parents 83f8ecb + 9fb7732 commit ae033ed
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public List<Group<GroupRepresentation>> getGroupsForUser() {
List<GroupRepresentation> groupRepresentations = keycloakUtil.getKeycloakUserGroups(user.get());

return (List) groupRepresentations.stream().
map(groupRepresentation -> repository.findByAuthProviderId(groupRepresentation.getId()).orElseThrow()).
collect(Collectors.toList());
map(groupRepresentation -> repository.findByAuthProviderId(groupRepresentation.getId()).orElse(null))
.filter(group -> group != null)
.collect(Collectors.toList());
}

public void setTransientRepresentations(Group<GroupRepresentation> group) {
Expand Down

0 comments on commit ae033ed

Please sign in to comment.