mirror of
https://github.com/bitwarden/server.git
synced 2025-04-24 14:26:38 -05:00

* work: baseline for org stuff * fix: missed view as usual oops * fix: refresh using sp_refreshsqlmodule
37 lines
1.6 KiB
C#
37 lines
1.6 KiB
C#
using Bit.Core.Models.Data.Organizations.OrganizationUsers;
|
|
|
|
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
|
|
|
public class OrganizationUserUserDetailsViewQuery : IQuery<OrganizationUserUserDetails>
|
|
{
|
|
public IQueryable<OrganizationUserUserDetails> Run(DatabaseContext dbContext)
|
|
{
|
|
var query = from ou in dbContext.OrganizationUsers
|
|
join u in dbContext.Users on ou.UserId equals u.Id into u_g
|
|
from u in u_g.DefaultIfEmpty()
|
|
join su in dbContext.SsoUsers on new { ou.UserId, OrganizationId = (Guid?)ou.OrganizationId } equals new { UserId = (Guid?)su.UserId, su.OrganizationId } into su_g
|
|
from su in su_g.DefaultIfEmpty()
|
|
select new { ou, u, su };
|
|
return query.Select(x => new OrganizationUserUserDetails
|
|
{
|
|
Id = x.ou.Id,
|
|
UserId = x.ou.UserId,
|
|
OrganizationId = x.ou.OrganizationId,
|
|
Name = x.u.Name,
|
|
Email = x.u.Email ?? x.ou.Email,
|
|
AvatarColor = x.u.AvatarColor,
|
|
TwoFactorProviders = x.u.TwoFactorProviders,
|
|
Premium = x.u.Premium,
|
|
Status = x.ou.Status,
|
|
Type = x.ou.Type,
|
|
AccessAll = x.ou.AccessAll,
|
|
ExternalId = x.ou.ExternalId,
|
|
SsoExternalId = x.su.ExternalId,
|
|
Permissions = x.ou.Permissions,
|
|
ResetPasswordKey = x.ou.ResetPasswordKey,
|
|
UsesKeyConnector = x.u != null && x.u.UsesKeyConnector,
|
|
AccessSecretsManager = x.ou.AccessSecretsManager,
|
|
});
|
|
}
|
|
}
|