|
1 | 1 | #nullable enable
|
2 | 2 | using System.Diagnostics;
|
3 |
| -using Bit.Core; |
4 | 3 | using Bit.Core.Context;
|
5 | 4 | using Bit.Core.Entities;
|
6 | 5 | using Bit.Core.Enums;
|
@@ -124,24 +123,15 @@ private async Task<bool> CanCreateAsync(CurrentContextOrganization? org)
|
124 | 123 | return true;
|
125 | 124 | }
|
126 | 125 |
|
127 |
| - if (_featureService.IsEnabled(FeatureFlagKeys.LimitCollectionCreationDeletionSplit)) |
128 |
| - { |
129 |
| - var userIsMemberOfOrg = org is not null; |
130 |
| - var limitCollectionCreationEnabled = await GetOrganizationAbilityAsync(org) is { LimitCollectionCreation: true }; |
131 |
| - var userIsOrgOwnerOrAdmin = org is { Type: OrganizationUserType.Owner or OrganizationUserType.Admin }; |
132 |
| - // If the limit collection management setting is disabled, allow any user to create collections |
133 |
| - if (userIsMemberOfOrg && (!limitCollectionCreationEnabled || userIsOrgOwnerOrAdmin)) |
134 |
| - { |
135 |
| - return true; |
136 |
| - } |
137 |
| - } |
138 |
| - else |
| 126 | + var organizationAbility = await GetOrganizationAbilityAsync(org); |
| 127 | + |
| 128 | + var userIsMemberOfOrg = org is not null; |
| 129 | + var limitCollectionCreationEnabled = await GetOrganizationAbilityAsync(org) is { LimitCollectionCreation: true }; |
| 130 | + var userIsOrgOwnerOrAdmin = org is { Type: OrganizationUserType.Owner or OrganizationUserType.Admin }; |
| 131 | + // If the limit collection management setting is disabled, allow any user to create collections |
| 132 | + if (userIsMemberOfOrg && (!limitCollectionCreationEnabled || userIsOrgOwnerOrAdmin)) |
139 | 133 | {
|
140 |
| - // If the limit collection management setting is disabled, allow any user to create collections |
141 |
| - if (await GetOrganizationAbilityAsync(org) is { LimitCollectionCreationDeletion: false }) |
142 |
| - { |
143 |
| - return true; |
144 |
| - } |
| 134 | + return true; |
145 | 135 | }
|
146 | 136 |
|
147 | 137 | // Allow provider users to create collections if they are a provider for the target organization
|
@@ -267,29 +257,13 @@ private async Task<bool> CanDeleteAsync(ICollection<Collection> resources, Curre
|
267 | 257 | return true;
|
268 | 258 | }
|
269 | 259 |
|
270 |
| - if (_featureService.IsEnabled(FeatureFlagKeys.LimitCollectionCreationDeletionSplit)) |
| 260 | + var userIsMemberOfOrg = org is not null; |
| 261 | + var limitCollectionDeletionEnabled = await GetOrganizationAbilityAsync(org) is { LimitCollectionDeletion: true }; |
| 262 | + var userIsOrgOwnerOrAdmin = org is { Type: OrganizationUserType.Owner or OrganizationUserType.Admin }; |
| 263 | + // If the limit collection management setting is disabled, allow any user to delete collections |
| 264 | + if (userIsMemberOfOrg && (!limitCollectionDeletionEnabled || userIsOrgOwnerOrAdmin) && await CanManageCollectionsAsync(resources, org)) |
271 | 265 | {
|
272 |
| - var userIsMemberOfOrg = org is not null; |
273 |
| - var limitCollectionDeletionEnabled = await GetOrganizationAbilityAsync(org) is { LimitCollectionDeletion: true }; |
274 |
| - var userIsOrgOwnerOrAdmin = org is { Type: OrganizationUserType.Owner or OrganizationUserType.Admin }; |
275 |
| - // If the limit collection management setting is disabled, allow any user to delete collections |
276 |
| - if (userIsMemberOfOrg && (!limitCollectionDeletionEnabled || userIsOrgOwnerOrAdmin) && await CanManageCollectionsAsync(resources, org)) |
277 |
| - { |
278 |
| - return true; |
279 |
| - } |
280 |
| - } |
281 |
| - else |
282 |
| - { |
283 |
| - // If LimitCollectionCreationDeletion is false, AllowAdminAccessToAllCollectionItems setting is irrelevant. |
284 |
| - // Ensure acting user has manage permissions for all collections being deleted |
285 |
| - // If LimitCollectionCreationDeletion is true, only Owners and Admins can delete collections they manage |
286 |
| - var organizationAbility = await GetOrganizationAbilityAsync(org); |
287 |
| - var canDeleteManagedCollections = organizationAbility is { LimitCollectionCreationDeletion: false } || |
288 |
| - org is { Type: OrganizationUserType.Owner or OrganizationUserType.Admin }; |
289 |
| - if (canDeleteManagedCollections && await CanManageCollectionsAsync(resources, org)) |
290 |
| - { |
291 |
| - return true; |
292 |
| - } |
| 266 | + return true; |
293 | 267 | }
|
294 | 268 |
|
295 | 269 | // Allow providers to delete collections if they are a provider for the target organization
|
|
0 commit comments