fixed iam with exclusive roles (in some cases?) being broken

This commit is contained in:
Toastie 2024-12-20 23:44:49 +13:00
parent 5d4e730f35
commit 6841c3969a
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4

View file

@ -280,8 +280,12 @@ public sealed class SarAssignerService : IEService, IReadyExecutor
if (item.Group.IsExclusive) if (item.Group.IsExclusive)
{ {
var rolesToRemove = item.Group.Roles.Select(x => x.RoleId); var rolesToRemove = item.Group.Roles
await item.User.RemoveRolesAsync(rolesToRemove); .Where(x => item.User.RoleIds.Contains(x.RoleId))
.Select(x => x.RoleId)
.ToArray();
if (rolesToRemove.Length > 0)
await item.User.RemoveRolesAsync(rolesToRemove);
} }
await item.User.AddRoleAsync(item.RoleId); await item.User.AddRoleAsync(item.RoleId);