mirror of
https://github.com/bitwarden/server.git
synced 2026-02-08 01:43:15 +08:00
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
|
|
using Bit.Core.Exceptions;
|
|||
|
|
using Bit.Core.OrganizationFeatures.OrganizationUsers.Interfaces;
|
|||
|
|
using Bit.Core.Repositories;
|
|||
|
|
using Bit.Core.Services;
|
|||
|
|
|
|||
|
|
namespace Bit.Core.OrganizationFeatures.OrganizationUsers;
|
|||
|
|
|
|||
|
|
public class DeleteOrganizationUserCommand : IDeleteOrganizationUserCommand
|
|||
|
|
{
|
|||
|
|
private readonly IOrganizationUserRepository _organizationUserRepository;
|
|||
|
|
private readonly IOrganizationService _organizationService;
|
|||
|
|
|
|||
|
|
public DeleteOrganizationUserCommand(
|
|||
|
|
IOrganizationUserRepository organizationUserRepository,
|
|||
|
|
IOrganizationService organizationService
|
|||
|
|
)
|
|||
|
|
{
|
|||
|
|
_organizationUserRepository = organizationUserRepository;
|
|||
|
|
_organizationService = organizationService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public async Task DeleteUserAsync(Guid organizationId, Guid organizationUserId, Guid? deletingUserId)
|
|||
|
|
{
|
|||
|
|
var orgUser = await _organizationUserRepository.GetByIdAsync(organizationUserId);
|
|||
|
|
if (orgUser == null || orgUser.OrganizationId != organizationId)
|
|||
|
|
{
|
|||
|
|
throw new NotFoundException("User not found.");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
await _organizationService.DeleteUserAsync(organizationId, organizationUserId, deletingUserId);
|
|||
|
|
}
|
|||
|
|
}
|