public virtual async Task UpdateMemberRolesAsync(Guid id, Guid userId, OrganizationUnitUpdateMemberRolesInput input)
        {
            var ou = await OrganizationUnitRepository.GetAsync(id, false);

            await AuthorizationService.CheckAsync(ou, CommonOperations.Update);

            var availableRoles = (await GetAvailableRolesAsync(ou.ParentId)).Select(r => r.Name).ToArray();

            input.RoleNames = input.RoleNames.Intersect(availableRoles).ToArray();
            var user = await UserManager.GetByIdAsync(userId);

            var userRoleNames = (await RoleRepository.GetListAsync())
                                .Where(r => user.Roles.Select(ur => ur.RoleId).Contains(r.Id))
                                .Select(r => r.Name).ToArray();

            await UserManager.SetRolesAsync(user, userRoleNames.Except(availableRoles).Union(input.RoleNames));
        }
Beispiel #2
0
 public async Task UpdateMemberRolesAsync(Guid id, Guid userId, OrganizationUnitUpdateMemberRolesInput input)
 {
     await _organizationUnitAppService.UpdateMemberRolesAsync(id, userId, input);
 }