mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
[AC-2436] Show unassigned items banner (#3967)
* Add endpoint * Add feature flag * Only show banner for flexible collections orgs (to avoid affecting self-host)
This commit is contained in:
parent
c15574721d
commit
2c36784cda
@ -1110,6 +1110,33 @@ public class CiphersController : Controller
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the user is an admin or owner of an organization with unassigned ciphers (i.e. ciphers that
|
||||
/// are not assigned to a collection).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("has-unassigned-ciphers")]
|
||||
public async Task<bool> HasUnassignedCiphers()
|
||||
{
|
||||
var orgAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync();
|
||||
|
||||
var adminOrganizations = _currentContext.Organizations
|
||||
.Where(o => o.Type is OrganizationUserType.Admin or OrganizationUserType.Owner &&
|
||||
orgAbilities.ContainsKey(o.Id) && orgAbilities[o.Id].FlexibleCollections);
|
||||
|
||||
foreach (var org in adminOrganizations)
|
||||
{
|
||||
var unassignedCiphers = await _cipherRepository.GetManyUnassignedOrganizationDetailsByOrganizationIdAsync(org.Id);
|
||||
// We only care about non-deleted ciphers
|
||||
if (unassignedCiphers.Any(c => c.DeletedDate == null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ValidateAttachment()
|
||||
{
|
||||
if (!Request?.ContentType.Contains("multipart/") ?? true)
|
||||
|
@ -132,6 +132,7 @@ public static class FeatureFlagKeys
|
||||
public const string ShowPaymentMethodWarningBanners = "show-payment-method-warning-banners";
|
||||
public const string EnableConsolidatedBilling = "enable-consolidated-billing";
|
||||
public const string AC1795_UpdatedSubscriptionStatusSection = "AC-1795_updated-subscription-status-section";
|
||||
public const string UnassignedItemsBanner = "unassigned-items-banner";
|
||||
|
||||
public static List<string> GetAllKeys()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user