mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
[AC-1784] Revert changes made on assigning Manage permission to collections (#3501)
This reverts commit fe702c6535
.
This commit is contained in:
@ -53,36 +53,21 @@ public class CollectionService : ICollectionService
|
||||
}
|
||||
|
||||
var groupsList = groups?.ToList();
|
||||
var usersList = users?.ToList() ?? new List<CollectionAccessSelection>();
|
||||
var usersList = users?.ToList();
|
||||
|
||||
// If using Flexible Collections - a collection should always have someone with Can Manage permissions
|
||||
if (_featureService.IsEnabled(FeatureFlagKeys.FlexibleCollections, _currentContext))
|
||||
{
|
||||
var groupHasManageAccess = groupsList?.Any(g => g.Manage) ?? false;
|
||||
var userHasManageAccess = usersList.Any(u => u.Manage);
|
||||
var userHasManageAccess = usersList?.Any(u => u.Manage) ?? false;
|
||||
if (!groupHasManageAccess && !userHasManageAccess)
|
||||
{
|
||||
throw new BadRequestException(
|
||||
"At least one member or group must have can manage permission.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If not using Flexible Collections
|
||||
// all Organization users with EditAssignedCollections permission should have Manage permission for the collection
|
||||
var organizationUsers = await _organizationUserRepository
|
||||
.GetManyByOrganizationAsync(collection.OrganizationId, null);
|
||||
foreach (var orgUser in organizationUsers.Where(ou => ou.GetPermissions()?.EditAssignedCollections ?? false))
|
||||
{
|
||||
var user = usersList.FirstOrDefault(u => u.Id == orgUser.Id);
|
||||
if (user != null)
|
||||
{
|
||||
user.Manage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (collection.Id == default)
|
||||
if (collection.Id == default(Guid))
|
||||
{
|
||||
if (org.MaxCollections.HasValue)
|
||||
{
|
||||
|
Reference in New Issue
Block a user