mirror of
https://github.com/bitwarden/server.git
synced 2024-11-29 13:25:17 +01:00
Refactor RemoveOrganizationUserCommand.RemoveUsersAsync to log in bulk
This commit is contained in:
parent
dececee4b9
commit
5eab00bf9c
@ -118,12 +118,12 @@ public class RemoveOrganizationUserCommand : IRemoveOrganizationUserCommand
|
||||
|
||||
if (usersToDelete.Any())
|
||||
{
|
||||
var eventDate = DateTime.UtcNow;
|
||||
await _organizationUserRepository.DeleteManyAsync(usersToDelete.Select(u => u.Id));
|
||||
await _eventService.LogOrganizationUserEventsAsync(usersToDelete.Select(u => (u, EventType.OrganizationUser_Removed, (DateTime?)eventDate)));
|
||||
|
||||
foreach (var orgUser in usersToDelete)
|
||||
{
|
||||
await _eventService.LogOrganizationUserEventAsync(orgUser, EventType.OrganizationUser_Removed);
|
||||
|
||||
if (orgUser.UserId.HasValue)
|
||||
{
|
||||
await DeleteAndPushUserRegistrationAsync(organizationId, orgUser.UserId.Value);
|
||||
|
@ -453,7 +453,10 @@ public class RemoveOrganizationUserCommandTests
|
||||
|
||||
await sutProvider.GetDependency<IEventService>()
|
||||
.Received(1)
|
||||
.LogOrganizationUserEventAsync(orgUser, EventType.OrganizationUser_Removed);
|
||||
.LogOrganizationUserEventsAsync(
|
||||
Arg.Is<IEnumerable<(OrganizationUser, EventType, DateTime?)>>(events =>
|
||||
events.Count() == 1
|
||||
&& events.Any(e => e.Item1.Id == orgUser.Id && e.Item2 == EventType.OrganizationUser_Removed)));
|
||||
}
|
||||
|
||||
[Theory, BitAutoData]
|
||||
@ -484,10 +487,11 @@ public class RemoveOrganizationUserCommandTests
|
||||
|
||||
await sutProvider.GetDependency<IEventService>()
|
||||
.Received(1)
|
||||
.LogOrganizationUserEventAsync(Arg.Is<OrganizationUser>(u => u.Id == orgUser1.Id), EventType.OrganizationUser_Removed);
|
||||
await sutProvider.GetDependency<IEventService>()
|
||||
.Received(1)
|
||||
.LogOrganizationUserEventAsync(Arg.Is<OrganizationUser>(u => u.Id == orgUser2.Id), EventType.OrganizationUser_Removed);
|
||||
.LogOrganizationUserEventsAsync(
|
||||
Arg.Is<IEnumerable<(OrganizationUser, EventType, DateTime?)>>(events =>
|
||||
events.Count() == 2
|
||||
&& events.Any(e => e.Item1.Id == orgUser1.Id && e.Item2 == EventType.OrganizationUser_Removed)
|
||||
&& events.Any(e => e.Item1.Id == orgUser2.Id && e.Item2 == EventType.OrganizationUser_Removed)));
|
||||
}
|
||||
|
||||
[Theory, BitAutoData]
|
||||
|
Loading…
Reference in New Issue
Block a user