mirror of
https://github.com/bitwarden/server.git
synced 2026-02-04 16:13:12 +08:00
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using Bit.Core.AdminConsole.Enums.Provider;
|
|
using Bit.Core.AdminConsole.Models.Data.Provider;
|
|
|
|
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
|
|
|
public class UserReadPublicKeysByProviderUserIdsQuery : IQuery<ProviderUserPublicKey>
|
|
{
|
|
private readonly Guid _providerId;
|
|
private readonly IEnumerable<Guid> _ids;
|
|
|
|
public UserReadPublicKeysByProviderUserIdsQuery(Guid providerId, IEnumerable<Guid> Ids)
|
|
{
|
|
_providerId = providerId;
|
|
_ids = Ids;
|
|
}
|
|
|
|
public virtual IQueryable<ProviderUserPublicKey> Run(DatabaseContext dbContext)
|
|
{
|
|
var query = from pu in dbContext.ProviderUsers
|
|
join u in dbContext.Users
|
|
on pu.UserId equals u.Id
|
|
where _ids.Contains(pu.Id) &&
|
|
pu.Status == ProviderUserStatusType.Accepted &&
|
|
pu.ProviderId == _providerId
|
|
select new { pu, u };
|
|
return query.Select(x => new ProviderUserPublicKey
|
|
{
|
|
Id = x.pu.Id,
|
|
PublicKey = x.u.PublicKey,
|
|
});
|
|
}
|
|
}
|