1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 09:02:48 -05:00

[PM-3007] Caching user policies on PolicyService variable (#3117)

* [PM-3007] Caching user policies on PolicyService variable

* [PM-3007] Added missing newlines on sql files
This commit is contained in:
Rui Tomé
2023-08-03 18:36:47 +01:00
committed by GitHub
parent 73c6421bd3
commit 78588d0246
8 changed files with 65 additions and 36 deletions

View File

@ -588,7 +588,7 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
}
}
public async Task<IEnumerable<OrganizationUserPolicyDetails>> GetByUserIdWithPolicyDetailsAsync(Guid userId, PolicyType policyType)
public async Task<IEnumerable<OrganizationUserPolicyDetails>> GetByUserIdWithPolicyDetailsAsync(Guid userId)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
@ -604,8 +604,7 @@ public class OrganizationUserRepository : Repository<Core.Entities.OrganizationU
join ou in dbContext.OrganizationUsers
on p.OrganizationId equals ou.OrganizationId
let email = dbContext.Users.Find(userId).Email // Invited orgUsers do not have a UserId associated with them, so we have to match up their email
where p.Type == policyType &&
(ou.UserId == userId || ou.Email == email)
where ou.UserId == userId || ou.Email == email
select new OrganizationUserPolicyDetails
{
OrganizationUserId = ou.Id,