1
0
mirror of https://github.com/bitwarden/server synced 2026-02-25 17:03:22 +00:00

[PM-29498] Remove Premium Feature Flagged Logic (#6967)

* Remove feature flag logic and fix unit tests

* Simplify query

* Fix test

* Fix local review
This commit is contained in:
sven-bitwarden
2026-02-19 08:06:17 -06:00
committed by GitHub
parent cfd5bedae0
commit 4d91350fb7
5 changed files with 60 additions and 312 deletions

View File

@@ -922,12 +922,7 @@ public class UserService : UserManager<User>, IUserService
return false;
}
if (_featureService.IsEnabled(FeatureFlagKeys.PremiumAccessQuery))
{
return user.Premium || await _hasPremiumAccessQuery.HasPremiumFromOrganizationAsync(userId.Value);
}
return user.Premium || await HasPremiumFromOrganization(user);
return user.Premium || await _hasPremiumAccessQuery.HasPremiumFromOrganizationAsync(userId.Value);
}
public async Task<bool> HasPremiumFromOrganization(User user)
@@ -938,25 +933,7 @@ public class UserService : UserManager<User>, IUserService
return false;
}
if (_featureService.IsEnabled(FeatureFlagKeys.PremiumAccessQuery))
{
return await _hasPremiumAccessQuery.HasPremiumFromOrganizationAsync(userId.Value);
}
// orgUsers in the Invited status are not associated with a userId yet, so this will get
// orgUsers in Accepted and Confirmed states only
var orgUsers = await _organizationUserRepository.GetManyByUserAsync(userId.Value);
if (!orgUsers.Any())
{
return false;
}
var orgAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync();
return orgUsers.Any(ou =>
orgAbilities.TryGetValue(ou.OrganizationId, out var orgAbility) &&
orgAbility.UsersGetPremium &&
orgAbility.Enabled);
return await _hasPremiumAccessQuery.HasPremiumFromOrganizationAsync(userId.Value);
}
public async Task<string> GenerateSignInTokenAsync(User user, string purpose)