mirror of
https://github.com/bitwarden/server.git
synced 2025-12-10 00:42:07 -06:00
Enhance EF UserRepository to improve premium access retrieval by including related organization data.
This commit is contained in:
parent
da9f0a1c20
commit
df7bd08dda
@ -281,18 +281,22 @@ public class UserRepository : Repository<Core.Entities.User, User, Guid>, IUserR
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var users = dbContext.Users.Where(x => ids.Contains(x.Id));
|
||||
return await users.Select(user => new UserPremiumAccess
|
||||
|
||||
var users = await dbContext.Users
|
||||
.Where(x => ids.Contains(x.Id))
|
||||
.Include(u => u.OrganizationUsers)
|
||||
.ThenInclude(ou => ou.Organization)
|
||||
.ToListAsync();
|
||||
|
||||
return users.Select(user => new UserPremiumAccess
|
||||
{
|
||||
Id = user.Id,
|
||||
PersonalPremium = user.Premium,
|
||||
OrganizationPremium = dbContext.OrganizationUsers
|
||||
.Any(ou => ou.UserId == user.Id &&
|
||||
dbContext.Organizations
|
||||
.Any(o => o.Id == ou.OrganizationId &&
|
||||
o.Enabled == true &&
|
||||
o.UsersGetPremium == true))
|
||||
}).ToListAsync();
|
||||
OrganizationPremium = user.OrganizationUsers
|
||||
.Any(ou => ou.Organization != null &&
|
||||
ou.Organization.Enabled == true &&
|
||||
ou.Organization.UsersGetPremium == true)
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user