1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -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

@ -19,7 +19,7 @@ namespace Bit.Core.Models.Business
public OrganizationLicense(Organization org, BillingInfo billingInfo, Guid installationId,
ILicensingService licenseService)
{
Version = 1;
Version = 2;
LicenseKey = org.LicenseKey;
InstallationId = installationId;
Id = org.Id;
@ -36,6 +36,7 @@ namespace Bit.Core.Models.Business
UseTotp = org.UseTotp;
MaxStorageGb = org.MaxStorageGb;
SelfHost = org.SelfHost;
UsersGetPremium = org.UsersGetPremium;
Issued = DateTime.UtcNow;
if(billingInfo?.Subscription == null)
@ -91,6 +92,7 @@ namespace Bit.Core.Models.Business
public bool UseTotp { get; set; }
public short? MaxStorageGb { get; set; }
public bool SelfHost { get; set; }
public bool UsersGetPremium { get; set; }
public int Version { get; set; }
public DateTime Issued { get; set; }
public DateTime? Refresh { get; set; }
@ -104,7 +106,7 @@ namespace Bit.Core.Models.Business
public byte[] GetDataBytes(bool forHash = false)
{
string data = null;
if(Version == 1)
if(Version == 1 || Version == 2)
{
var props = typeof(OrganizationLicense)
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
@ -147,7 +149,7 @@ namespace Bit.Core.Models.Business
return false;
}
if(Version == 1)
if(Version == 1 || Version == 2)
{
return InstallationId == globalSettings.Installation.Id && SelfHost;
}
@ -164,9 +166,9 @@ namespace Bit.Core.Models.Business
return false;
}
if(Version == 1)
if(Version == 1 || Version == 2)
{
return
var valid =
globalSettings.Installation.Id == InstallationId &&
organization.LicenseKey.Equals(LicenseKey) &&
organization.Enabled == Enabled &&
@ -178,6 +180,13 @@ namespace Bit.Core.Models.Business
organization.UseTotp == UseTotp &&
organization.SelfHost == SelfHost &&
organization.Name.Equals(Name);
if(valid && Version == 2)
{
valid = organization.UsersGetPremium = UsersGetPremium;
}
return valid;
}
else
{

View File

@ -10,6 +10,8 @@ namespace Bit.Core.Models.Data
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseTotp { get; set; }
public bool SelfHost { get; set; }
public bool UsersGetPremium { get; set; }
public int Seats { get; set; }
public int MaxCollections { get; set; }
public short? MaxStorageGb { get; set; }

View File

@ -23,5 +23,6 @@ namespace Bit.Core.Models.StaticStore
public bool Disabled { get; set; }
public int? TrialPeriodDays { get; set; }
public bool SelfHost { get; set; }
public bool UsersGetPremium { get; set; }
}
}

View File

@ -25,6 +25,7 @@ namespace Bit.Core.Models.Table
public bool UseDirectory { get; set; }
public bool UseTotp { get; set; }
public bool SelfHost { get; set; }
public bool UsersGetPremium { get; set; }
public long? Storage { get; set; }
public short? MaxStorageGb { get; set; }
public GatewayType? Gateway { get; set; }