1
0
mirror of https://github.com/bitwarden/server synced 2025-12-24 20:23:21 +00:00

Run formatting (#2230)

This commit is contained in:
Justin Baur
2022-08-29 16:06:55 -04:00
committed by GitHub
parent 9b7aef0763
commit 7f5f010e1e
1205 changed files with 73813 additions and 75022 deletions

View File

@@ -1,56 +1,55 @@
using Bit.Core.Enums;
using Bit.Infrastructure.EntityFramework.Models;
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries
namespace Bit.Infrastructure.EntityFramework.Repositories.Queries;
public class CipherReadCanEditByIdUserIdQuery : IQuery<Cipher>
{
public class CipherReadCanEditByIdUserIdQuery : IQuery<Cipher>
private readonly Guid _userId;
private readonly Guid _cipherId;
public CipherReadCanEditByIdUserIdQuery(Guid userId, Guid cipherId)
{
private readonly Guid _userId;
private readonly Guid _cipherId;
_userId = userId;
_cipherId = cipherId;
}
public CipherReadCanEditByIdUserIdQuery(Guid userId, Guid cipherId)
{
_userId = userId;
_cipherId = cipherId;
}
public virtual IQueryable<Cipher> Run(DatabaseContext dbContext)
{
var query = from c in dbContext.Ciphers
join o in dbContext.Organizations
on c.OrganizationId equals o.Id into o_g
from o in o_g.DefaultIfEmpty()
where !c.UserId.HasValue
join ou in dbContext.OrganizationUsers
on o.Id equals ou.OrganizationId into ou_g
from ou in ou_g.DefaultIfEmpty()
where ou.UserId == _userId
join cc in dbContext.CollectionCiphers
on c.Id equals cc.CipherId into cc_g
from cc in cc_g.DefaultIfEmpty()
where !c.UserId.HasValue && !ou.AccessAll
join cu in dbContext.CollectionUsers
on cc.CollectionId equals cu.CollectionId into cu_g
from cu in cu_g.DefaultIfEmpty()
where ou.Id == cu.OrganizationUserId
join gu in dbContext.GroupUsers
on ou.Id equals gu.OrganizationUserId into gu_g
from gu in gu_g.DefaultIfEmpty()
where !c.UserId.HasValue && cu.CollectionId == null && !ou.AccessAll
join g in dbContext.Groups
on gu.GroupId equals g.Id into g_g
from g in g_g.DefaultIfEmpty()
join cg in dbContext.CollectionGroups
on gu.GroupId equals cg.GroupId into cg_g
from cg in cg_g.DefaultIfEmpty()
where !g.AccessAll && cg.CollectionId == cc.CollectionId &&
(c.Id == _cipherId &&
(c.UserId == _userId ||
(!c.UserId.HasValue && ou.Status == OrganizationUserStatusType.Confirmed && o.Enabled &&
(ou.AccessAll || cu.CollectionId != null || g.AccessAll || cg.CollectionId != null)))) &&
(c.UserId.HasValue || ou.AccessAll || !cu.ReadOnly || g.AccessAll || !cg.ReadOnly)
select c;
return query;
}
public virtual IQueryable<Cipher> Run(DatabaseContext dbContext)
{
var query = from c in dbContext.Ciphers
join o in dbContext.Organizations
on c.OrganizationId equals o.Id into o_g
from o in o_g.DefaultIfEmpty()
where !c.UserId.HasValue
join ou in dbContext.OrganizationUsers
on o.Id equals ou.OrganizationId into ou_g
from ou in ou_g.DefaultIfEmpty()
where ou.UserId == _userId
join cc in dbContext.CollectionCiphers
on c.Id equals cc.CipherId into cc_g
from cc in cc_g.DefaultIfEmpty()
where !c.UserId.HasValue && !ou.AccessAll
join cu in dbContext.CollectionUsers
on cc.CollectionId equals cu.CollectionId into cu_g
from cu in cu_g.DefaultIfEmpty()
where ou.Id == cu.OrganizationUserId
join gu in dbContext.GroupUsers
on ou.Id equals gu.OrganizationUserId into gu_g
from gu in gu_g.DefaultIfEmpty()
where !c.UserId.HasValue && cu.CollectionId == null && !ou.AccessAll
join g in dbContext.Groups
on gu.GroupId equals g.Id into g_g
from g in g_g.DefaultIfEmpty()
join cg in dbContext.CollectionGroups
on gu.GroupId equals cg.GroupId into cg_g
from cg in cg_g.DefaultIfEmpty()
where !g.AccessAll && cg.CollectionId == cc.CollectionId &&
(c.Id == _cipherId &&
(c.UserId == _userId ||
(!c.UserId.HasValue && ou.Status == OrganizationUserStatusType.Confirmed && o.Enabled &&
(ou.AccessAll || cu.CollectionId != null || g.AccessAll || cg.CollectionId != null)))) &&
(c.UserId.HasValue || ou.AccessAll || !cu.ReadOnly || g.AccessAll || !cg.ReadOnly)
select c;
return query;
}
}