From 3f5a0a824926ef4a73c032348f84b687650c4a0a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 11 Oct 2018 14:51:55 -0400 Subject: [PATCH] Official premium no longer given by org assignment --- .../Implementations/LicensingService.cs | 38 ------------------- .../Implementations/OrganizationService.cs | 19 ---------- 2 files changed, 57 deletions(-) diff --git a/src/Core/Services/Implementations/LicensingService.cs b/src/Core/Services/Implementations/LicensingService.cs index d766fe3d5..27cdf0683 100644 --- a/src/Core/Services/Implementations/LicensingService.cs +++ b/src/Core/Services/Implementations/LicensingService.cs @@ -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 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, diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index d5e72b1b2..505398a41 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -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());