throw error when assigning role to a user who is not found in the aai registry

This commit is contained in:
Konstantinos Spyrou 2023-02-17 17:35:18 +02:00
parent bae9a132cb
commit 0ad86025b3
1 changed files with 3 additions and 0 deletions

View File

@ -88,6 +88,9 @@ public class AuthorizationServiceImpl implements AuthorizationService {
throw new ResourceNotFoundException("Cannot find CouId for role: " + role);
}
List<Integer> coPersonIds = aaiRegistryService.getCoPersonIdsByEmail(email);
if (coPersonIds.isEmpty()) {
throw new ResourceNotFoundException("User with email '%s' could not be found..");
}
for (Integer coPersonId : coPersonIds) {
assert coPersonId != null;
aaiRegistryService.assignMemberRole(coPersonId, couId);