1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 09:32:48 -05:00

change personal plan to family. allow self host

This commit is contained in:
Kyle Spearrin
2017-11-06 16:01:58 -05:00
parent dccdef6db5
commit 0fdb9b3d2f
14 changed files with 282 additions and 23 deletions

View File

@ -112,10 +112,10 @@ namespace Bit.Core.Services
foreach(var user in nonPremiumUsers)
{
var details = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id);
if(details.Any(d => d.Enabled))
if(details.Any(d => d.SelfHost && d.UsersGetPremium && d.Enabled))
{
_logger.LogInformation("Granting premium to user {0}({1}) because they are in an active organization.",
user.Id, user.Email);
_logger.LogInformation("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
@ -170,7 +170,7 @@ namespace Bit.Core.Services
if(!valid)
{
var details = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id);
valid = details.Any(d => d.Enabled);
valid = details.Any(d => d.SelfHost && d.UsersGetPremium && d.Enabled);
if(valid && (!string.IsNullOrWhiteSpace(user.LicenseKey) || user.PremiumExpirationDate.HasValue))
{

View File

@ -527,6 +527,7 @@ namespace Bit.Core.Services
UseDirectory = plan.UseDirectory,
UseTotp = plan.UseTotp,
SelfHost = plan.SelfHost,
UsersGetPremium = plan.UsersGetPremium,
Plan = plan.Name,
Gateway = plan.Type == PlanType.Free ? null : (GatewayType?)GatewayType.Stripe,
GatewayCustomerId = customer?.Id,
@ -581,6 +582,7 @@ namespace Bit.Core.Services
UseTotp = license.UseTotp,
Plan = license.Plan,
SelfHost = license.SelfHost,
UsersGetPremium = license.UsersGetPremium,
Gateway = null,
GatewayCustomerId = null,
GatewaySubscriptionId = null,
@ -597,8 +599,8 @@ namespace Bit.Core.Services
Directory.CreateDirectory(dir);
File.WriteAllText($"{dir}/{organization.Id}.json", JsonConvert.SerializeObject(license, Formatting.Indented));
// self-hosted org users get premium access
if(!owner.Premium && result.Item1.Enabled)
// 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
@ -1003,7 +1005,7 @@ namespace Bit.Core.Services
await _mailService.SendOrganizationConfirmedEmailAsync(org.Name, user.Email);
// self-hosted org users get premium access
if(_globalSettings.SelfHosted && !user.Premium && org.Enabled)
if(_globalSettings.SelfHosted && !user.Premium && org.UsersGetPremium && org.Enabled)
{
user.Premium = true;
user.MaxStorageGb = 10240; // 10 TB