1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

Fixes the dupe issue on group and colletion (#4743)

This commit is contained in:
Tom 2024-09-09 11:48:07 -04:00 committed by GitHub
parent afa9620f35
commit aa72c0b800
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -72,6 +72,11 @@ public class MemberAccessReportResponseModel
(key, g) => new { CollectionId = key, Ciphers = g }); (key, g) => new { CollectionId = key, Ciphers = g });
var collectionItemCounts = collectionItems.ToDictionary(x => x.CollectionId, x => x.Ciphers.Count()); var collectionItemCounts = collectionItems.ToDictionary(x => x.CollectionId, x => x.Ciphers.Count());
// Loop through the org users and populate report and access data
var memberAccessReport = new List<MemberAccessReportResponseModel>();
foreach (var user in orgUsers)
{
// Take the collections/groups and create the access details items // Take the collections/groups and create the access details items
var groupAccessDetails = new List<MemberAccessReportAccessDetails>(); var groupAccessDetails = new List<MemberAccessReportAccessDetails>();
var userCollectionAccessDetails = new List<MemberAccessReportAccessDetails>(); var userCollectionAccessDetails = new List<MemberAccessReportAccessDetails>();
@ -80,7 +85,7 @@ public class MemberAccessReportResponseModel
var itemCounts = collectionItemCounts.TryGetValue(tCollect.Item1.Id, out var itemCount) ? itemCount : 0; var itemCounts = collectionItemCounts.TryGetValue(tCollect.Item1.Id, out var itemCount) ? itemCount : 0;
if (tCollect.Item2.Groups.Count() > 0) if (tCollect.Item2.Groups.Count() > 0)
{ {
var groupDetails = tCollect.Item2.Groups.Select(x => var groupDetails = tCollect.Item2.Groups.Where((tCollectGroups) => user.Groups.Contains(tCollectGroups.Id)).Select(x =>
new MemberAccessReportAccessDetails new MemberAccessReportAccessDetails
{ {
CollectionId = tCollect.Item1.Id, CollectionId = tCollect.Item1.Id,
@ -98,7 +103,7 @@ public class MemberAccessReportResponseModel
// All collections assigned to users and their permissions // All collections assigned to users and their permissions
if (tCollect.Item2.Users.Count() > 0) if (tCollect.Item2.Users.Count() > 0)
{ {
var userCollectionDetails = tCollect.Item2.Users.Select(x => var userCollectionDetails = tCollect.Item2.Users.Where((tCollectUser) => tCollectUser.Id == user.Id).Select(x =>
new MemberAccessReportAccessDetails new MemberAccessReportAccessDetails
{ {
CollectionId = tCollect.Item1.Id, CollectionId = tCollect.Item1.Id,
@ -112,10 +117,6 @@ public class MemberAccessReportResponseModel
} }
} }
// Loop through the org users and populate report and access data
var memberAccessReport = new List<MemberAccessReportResponseModel>();
foreach (var user in orgUsers)
{
var report = new MemberAccessReportResponseModel var report = new MemberAccessReportResponseModel
{ {
UserName = user.Name, UserName = user.Name,