1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 01:22:50 -05:00

[PS-1928] Fix User Delete (#2463)

* Fix User Delete

* Formatting
This commit is contained in:
Justin Baur
2022-12-02 19:35:26 -05:00
committed by GitHub
parent 1652669667
commit 85e75c43b5
5 changed files with 56 additions and 76 deletions

View File

@ -179,8 +179,16 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
public async Task<int> GetCountByOnlyOwnerAsync(Guid userId)
{
var query = new OrganizationUserReadCountByOnlyOwnerQuery(userId);
return await GetCountFromQuery(query);
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
return await dbContext.OrganizationUsers
.Where(ou => ou.Type == OrganizationUserType.Owner && ou.Status == OrganizationUserStatusType.Confirmed)
.GroupBy(ou => ou.UserId)
.Select(g => new { UserId = g.Key, ConfirmedOwnerCount = g.Count() })
.Where(oc => oc.UserId == userId && oc.ConfirmedOwnerCount == 1)
.CountAsync();
}
}
public async Task<int> GetCountByOrganizationAsync(Guid organizationId, string email, bool onlyRegisteredUsers)