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)
{
var rolesToRemove = item.Group.Roles.Select(x => x.RoleId);
await item.User.RemoveRolesAsync(rolesToRemove);
var rolesToRemove = item.Group.Roles
.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);