1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-27 22:41:22 +01:00

PS-1806 fix boolean logic with UserCollectionDetailsQuery query (#2424)

* fix logic in user collection details query

* remove pragma

* remove pragma
This commit is contained in:
Kyle Spearrin 2022-11-18 14:44:59 -05:00 committed by GitHub
parent 194dfe7e14
commit 68bb545353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,8 +45,7 @@ public class UserCollectionDetailsQuery : IQuery<CollectionDetails>
o.Enabled &&
(ou.AccessAll || cu.CollectionId != null || g.AccessAll || cg.CollectionId != null)
select new { c, ou, o, cu, gu, g, cg };
#pragma warning disable IDE0075
// I want to leave the ReadOnly and HidePasswords the way they are because it helps show the exact logic we are trying to replicate
return query.Select(x => new CollectionDetails
{
Id = x.c.Id,
@ -55,11 +54,10 @@ public class UserCollectionDetailsQuery : IQuery<CollectionDetails>
ExternalId = x.c.ExternalId,
CreationDate = x.c.CreationDate,
RevisionDate = x.c.RevisionDate,
ReadOnly = x.ou.AccessAll || x.g.AccessAll || ((x.cu != null ? x.cu.ReadOnly : (bool?)null) ?? (x.cg != null ? x.cg.ReadOnly : (bool?)null) ?? false) ? false : true,
HidePasswords = x.ou.AccessAll || x.g.AccessAll || ((x.cu != null ? x.cu.HidePasswords : (bool?)null) ?? (x.cg != null ? x.cg.HidePasswords : (bool?)null) ?? false) ? false : true,
ReadOnly = x.ou.AccessAll || x.g.AccessAll ||
!((bool?)x.cu.ReadOnly ?? (bool?)x.cg.ReadOnly ?? false) ? false : true,
HidePasswords = x.ou.AccessAll || x.g.AccessAll ||
!((bool?)x.cu.HidePasswords ?? (bool?)x.cg.HidePasswords ?? false) ? false : true,
});
#pragma warning restore IDE0075
}
}