mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
Official premium no longer given by org assignment
This commit is contained in:
parent
7705776d6a
commit
3f5a0a8249
@ -120,28 +120,6 @@ namespace Bit.Core.Services
|
||||
{
|
||||
await ProcessUserValidationAsync(user);
|
||||
}
|
||||
|
||||
var nonPremiumUsers = await _userRepository.GetManyByPremiumAsync(false);
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, null,
|
||||
"Checking to restore premium for {0} users.", nonPremiumUsers.Count);
|
||||
|
||||
foreach(var user in nonPremiumUsers)
|
||||
{
|
||||
var details = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id);
|
||||
if(details.Any(d => d.SelfHost && d.UsersGetPremium && d.Enabled))
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, null,
|
||||
"Granting premium to user {0}({1}) because they are in an active organization " +
|
||||
"with premium features.", user.Id, user.Email);
|
||||
|
||||
user.Premium = true;
|
||||
user.MaxStorageGb = 10240; // 10 TB
|
||||
user.RevisionDate = DateTime.UtcNow;
|
||||
user.PremiumExpirationDate = null;
|
||||
user.LicenseKey = null;
|
||||
await _userRepository.ReplaceAsync(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> ValidateUserPremiumAsync(User user)
|
||||
@ -184,22 +162,6 @@ namespace Bit.Core.Services
|
||||
{
|
||||
var license = ReadUserLicense(user);
|
||||
var valid = license != null && license.VerifyData(user) && license.VerifySignature(_certificate);
|
||||
|
||||
if(!valid)
|
||||
{
|
||||
var details = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id);
|
||||
valid = details.Any(d => d.SelfHost && d.UsersGetPremium && d.Enabled);
|
||||
|
||||
if(valid && (!string.IsNullOrWhiteSpace(user.LicenseKey) || user.PremiumExpirationDate.HasValue))
|
||||
{
|
||||
// user used to be on a license but is now part of a organization that gives them premium.
|
||||
// update the record.
|
||||
user.PremiumExpirationDate = null;
|
||||
user.LicenseKey = null;
|
||||
await _userRepository.ReplaceAsync(user);
|
||||
}
|
||||
}
|
||||
|
||||
if(!valid)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, null,
|
||||
|
@ -610,16 +610,6 @@ namespace Bit.Core.Services
|
||||
var dir = $"{_globalSettings.LicenseDirectory}/organization";
|
||||
Directory.CreateDirectory(dir);
|
||||
File.WriteAllText($"{dir}/{organization.Id}.json", JsonConvert.SerializeObject(license, Formatting.Indented));
|
||||
|
||||
// self-hosted org users get premium access on some plans
|
||||
if(organization.UsersGetPremium && !owner.Premium && result.Item1.Enabled)
|
||||
{
|
||||
owner.Premium = true;
|
||||
owner.MaxStorageGb = 10240; // 10 TB
|
||||
owner.RevisionDate = DateTime.UtcNow;
|
||||
await _userRepository.ReplaceAsync(owner);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1065,15 +1055,6 @@ namespace Bit.Core.Services
|
||||
var user = await _userRepository.GetByIdAsync(orgUser.UserId.Value);
|
||||
await _mailService.SendOrganizationConfirmedEmailAsync(org.Name, user.Email);
|
||||
|
||||
// self-hosted org users get premium access
|
||||
if(_globalSettings.SelfHosted && !user.Premium && org.UsersGetPremium && org.Enabled)
|
||||
{
|
||||
user.Premium = true;
|
||||
user.MaxStorageGb = 10240; // 10 TB
|
||||
user.RevisionDate = DateTime.UtcNow;
|
||||
await _userRepository.ReplaceAsync(user);
|
||||
}
|
||||
|
||||
// push
|
||||
var deviceIds = await GetUserDeviceIdsAsync(orgUser.UserId.Value);
|
||||
await _pushRegistrationService.AddUserRegistrationOrganizationAsync(deviceIds, organizationId.ToString());
|
||||
|
Loading…
Reference in New Issue
Block a user