Files
server/src/Infrastructure.EntityFramework/Repositories/Queries/PolicyReadByUserIdQuery.cs
Jared Snider a791f93051 Defect/SG-825 - users in org w/ no personal vault still see personal vault (disabled org policies now still apply) (#2429)
* SG-825 - Policy_ReadByUserId stored proc now pulls back policies of disabled orgs

* SG-825 - SyncController - Always retrieve policies -- even if orgs are disabled.

* SG-825 - EF - PolicyReadByUserId - autoformat to remove whitespace and pass eslint build error
2022-12-16 15:22:39 -05:00

29 lines
862 B
C#

using Bit.Core.Enums;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
public class PolicyReadByUserIdQuery : IQuery<Policy>
{
private readonly Guid _userId;
public PolicyReadByUserIdQuery(Guid userId)
{
_userId = userId;
}
public IQueryable<Policy> Run(DatabaseContext dbContext)
{
var query = from p in dbContext.Policies
join ou in dbContext.OrganizationUsers
on p.OrganizationId equals ou.OrganizationId
join o in dbContext.Organizations
on ou.OrganizationId equals o.Id
where ou.UserId == _userId &&
ou.Status == OrganizationUserStatusType.Confirmed
select p;
return query;
}
}