Skip to content

Commit

Permalink
fix(role-management): fix query selecting role-data for core-offer ro…
Browse files Browse the repository at this point in the history
…le assignement (#749)
  • Loading branch information
ntruchsess committed May 21, 2024
1 parent 87cfaa4 commit d7fd0cc
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,16 @@ public async IAsyncEnumerable<Guid> GetUserRoleIdsUntrackedAsync(IEnumerable<Use
.Select(role => new
{
Role = role,
IsRequested = userRoles.Contains(role.UserRoleText),
IsAssigned = role.IdentityAssignedRoles.Any(iar => iar.IdentityId == identityId),
IsAssignable = role.UserRoleCollections.Any(collection => collection.CompanyRoleAssignedRoleCollection!.CompanyRole!.CompanyAssignedRoles.Any(assigned => assigned.Company!.Identities.Any(identity => identity.Id == identityId)))
})
.Where(x =>
userRoles.Contains(x.Role.UserRoleText) ||
x.IsAssigned ||
x.IsAssignable)
// x.IsRequested && x.IsAssigned && x.IsAssignable || // no change but required to detect duplicates
// x.IsRequested && !x.IsAssigned && x.IsAssignable || // to be assigned
// !x.IsRequested && x.IsAssigned || // to be unassigned
// x.IsRequested && !x.IsAssignable // invalid
// can be simplified to:
.Where(x => x.IsRequested || x.IsAssigned)
.Select(x => new UserRoleModificationData(
x.Role.UserRoleText,
x.Role.Id,
Expand Down

0 comments on commit d7fd0cc

Please sign in to comment.