mirror of
https://github.com/bitwarden/server.git
synced 2026-02-02 07:03:11 +08:00
* this updates namespace and content for IPolicyData.cs and Entityframework Policy.cs as a separate commit to maintain git history.
31 lines
1006 B
C#
31 lines
1006 B
C#
using Bit.Core.Enums;
|
|
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
|
using Bit.Infrastructure.EntityFramework.Repositories;
|
|
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
|
|
|
namespace Bit.Infrastructure.EntityFramework.AdminConsole.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;
|
|
}
|
|
}
|