Browse Source

[AC-1889] Fix ManageGroups custom permission not getting all collections (#3514)

pull/3539/head
Thomas Rittson 2 years ago committed by GitHub
parent
commit
ce6768114b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/Api/Controllers/CollectionsController.cs

18
src/Api/Controllers/CollectionsController.cs

@ -165,7 +165,23 @@ public class CollectionsController : Controller @@ -165,7 +165,23 @@ public class CollectionsController : Controller
}
// Old pre-flexible collections logic follows
var orgCollections = await _collectionService.GetOrganizationCollectionsAsync(orgId);
IEnumerable<Collection> orgCollections = null;
if (await _currentContext.ManageGroups(orgId))
{
// ManageGroups users need to see all collections to manage other users' collection access.
// This is not added to collectionService.GetOrganizationCollectionsAsync as that may have
// unintended consequences on other logic that also uses that method.
// This is a quick fix but it will be properly fixed by permission changes in Flexible Collections.
// Get all collections for organization
orgCollections = await _collectionRepository.GetManyByOrganizationIdAsync(orgId);
}
else
{
// Returns all collections or collections the user is assigned to, depending on permissions
orgCollections = await _collectionService.GetOrganizationCollectionsAsync(orgId);
}
var responses = orgCollections.Select(c => new CollectionResponseModel(c));
return new ListResponseModel<CollectionResponseModel>(responses);
}

Loading…
Cancel
Save