diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 588f2235f2..6d90710e07 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -1539,7 +1539,7 @@ namespace Bit.Core.Services } var owners = filteredUsers.Where(u => u.Type == OrganizationUserType.Owner); - if (!owners.Any() && deletingUserId.HasValue && !await UserIsOwnerAsync(organizationId, deletingUserId.Value)) + if (owners.Any() && deletingUserId.HasValue && !await UserIsOwnerAsync(organizationId, deletingUserId.Value)) { throw new BadRequestException("Only owners can delete other owners."); } diff --git a/test/Core.Test/Services/OrganizationServiceTests.cs b/test/Core.Test/Services/OrganizationServiceTests.cs index ef6c32921c..f92d017866 100644 --- a/test/Core.Test/Services/OrganizationServiceTests.cs +++ b/test/Core.Test/Services/OrganizationServiceTests.cs @@ -462,6 +462,7 @@ namespace Bit.Core.Test.Services var organizationUserRepository = sutProvider.GetDependency(); deletingUser.Type = OrganizationUserType.Admin; + orgUser1.Type = OrganizationUserType.Owner; orgUser1.OrganizationId = orgUser2.OrganizationId = deletingUser.OrganizationId; var organizationUsers = new[] { orgUser1, orgUser2 }; var organizationUserIds = organizationUsers.Select(u => u.Id);