Skip to content

Commit

Permalink
Hotfix to catch MisconfiguredUserException (#8368)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbrown authored Dec 19, 2024
1 parent f939996 commit ead9fae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,14 @@ private UserInfo consolidateUser(ApiUser apiUser, PartialOktaUser oktaUser) {
OrganizationRoles orgRoles =
getOrganizationRoles(Optional.ofNullable(oktaClaims), apiUser, isSiteAdmin);

_dbOrgRoleClaimsService.checkOrgRoleClaimsEquality(
List.of(oktaClaims),
List.of(_dbOrgRoleClaimsService.getOrganizationRoleClaims(apiUser)),
apiUser.getLoginEmail());
try {
_dbOrgRoleClaimsService.checkOrgRoleClaimsEquality(
List.of(oktaClaims),
List.of(_dbOrgRoleClaimsService.getOrganizationRoleClaims(apiUser)),
apiUser.getLoginEmail());
} catch (MisconfiguredUserException e) {
log.error("Misconfigured organizations in DB for User ID: {}", apiUser.getInternalId());
}
return new UserInfo(apiUser, Optional.of(orgRoles), isSiteAdmin, userStatus);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ public List<OrganizationRoleClaims> getOrganizationRoleClaims(String username) {
public OrganizationRoleClaims getOrganizationRoleClaims(ApiUser user) {
Set<Organization> orgs = user.getOrganizations();
if (orgs.size() != 1) {
log.error("Misconfigured organizations in DB for User ID: {}", user.getInternalId());
log.error(
"Misconfigured organizations in DB for User ID: {}. Number of organizations for user was: {}",
user.getInternalId(),
orgs.size());
throw new MisconfiguredUserException();
}
Set<OrganizationRole> roles = user.getRoles();
Expand Down

0 comments on commit ead9fae

Please sign in to comment.