1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -05:00

added org flag for UseEvents

This commit is contained in:
Kyle Spearrin
2017-12-14 15:48:44 -05:00
parent 2c4ce27ef2
commit 172fd2425e
15 changed files with 305 additions and 7 deletions

View File

@ -31,6 +31,7 @@ namespace Bit.Core.Models.Api
MaxCollections = organization.MaxCollections;
UseGroups = organization.UseGroups;
UseDirectory = organization.UseDirectory;
UseEvents = organization.UseEvents;
UseTotp = organization.UseTotp;
}
@ -49,6 +50,7 @@ namespace Bit.Core.Models.Api
public short? MaxCollections { get; set; }
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }
public bool UseTotp { get; set; }
}

View File

@ -12,6 +12,7 @@ namespace Bit.Core.Models.Api
Name = organization.Name;
UseGroups = organization.UseGroups;
UseDirectory = organization.UseDirectory;
UseEvents = organization.UseEvents;
UseTotp = organization.UseTotp;
Seats = organization.Seats;
MaxCollections = organization.MaxCollections;
@ -26,6 +27,7 @@ namespace Bit.Core.Models.Api
public string Name { get; set; }
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }
public bool UseTotp { get; set; }
public int Seats { get; set; }
public int MaxCollections { get; set; }

View File

@ -19,7 +19,7 @@ namespace Bit.Core.Models.Business
public OrganizationLicense(Organization org, BillingInfo billingInfo, Guid installationId,
ILicensingService licenseService)
{
Version = 2;
Version = 3;
LicenseKey = org.LicenseKey;
InstallationId = installationId;
Id = org.Id;
@ -32,6 +32,7 @@ namespace Bit.Core.Models.Business
Seats = org.Seats;
MaxCollections = org.MaxCollections;
UseGroups = org.UseGroups;
UseEvents = org.UseEvents;
UseDirectory = org.UseDirectory;
UseTotp = org.UseTotp;
MaxStorageGb = org.MaxStorageGb;
@ -96,6 +97,7 @@ namespace Bit.Core.Models.Business
public short? Seats { get; set; }
public short? MaxCollections { get; set; }
public bool UseGroups { get; set; }
public bool UseEvents { get; set; }
public bool UseDirectory { get; set; }
public bool UseTotp { get; set; }
public short? MaxStorageGb { get; set; }
@ -114,7 +116,7 @@ namespace Bit.Core.Models.Business
public byte[] GetDataBytes(bool forHash = false)
{
string data = null;
if(Version == 1 || Version == 2)
if(Version >= 1 && Version <= 3)
{
var props = typeof(OrganizationLicense)
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
@ -122,7 +124,9 @@ namespace Bit.Core.Models.Business
!p.Name.Equals(nameof(Signature)) &&
!p.Name.Equals(nameof(SignatureBytes)) &&
// UsersGetPremium was added in Version 2
(Version > 1 || !p.Name.Equals(nameof(UsersGetPremium))) &&
(Version >= 2 || !p.Name.Equals(nameof(UsersGetPremium))) &&
// UseEvents was added in Version 3
(Version >= 3 || !p.Name.Equals(nameof(UseEvents))) &&
(
!forHash ||
(
@ -159,7 +163,7 @@ namespace Bit.Core.Models.Business
return false;
}
if(Version == 1 || Version == 2)
if(Version >= 1 && Version <= 3)
{
return InstallationId == globalSettings.Installation.Id && SelfHost;
}
@ -176,7 +180,7 @@ namespace Bit.Core.Models.Business
return false;
}
if(Version == 1 || Version == 2)
if(Version >= 1 && Version <= 3)
{
var valid =
globalSettings.Installation.Id == InstallationId &&
@ -191,11 +195,16 @@ namespace Bit.Core.Models.Business
organization.SelfHost == SelfHost &&
organization.Name.Equals(Name);
if(valid && Version == 2)
if(valid && Version >= 2)
{
valid = organization.UsersGetPremium == UsersGetPremium;
}
if(valid && Version >= 3)
{
valid = organization.UseEvents == UseEvents;
}
return valid;
}
else

View File

@ -9,6 +9,7 @@ namespace Bit.Core.Models.Data
public string Name { get; set; }
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }
public bool UseTotp { get; set; }
public bool SelfHost { get; set; }
public bool UsersGetPremium { get; set; }

View File

@ -14,6 +14,7 @@ namespace Bit.Core.Models.StaticStore
public short? MaxAdditionalSeats { get; set; }
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }
public bool UseTotp { get; set; }
public short? MaxStorageGb { get; set; }
public decimal BasePrice { get; set; }

View File

@ -23,6 +23,7 @@ namespace Bit.Core.Models.Table
public short? MaxCollections { get; set; }
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }
public bool UseTotp { get; set; }
public bool SelfHost { get; set; }
public bool UsersGetPremium { get; set; }

View File

@ -527,6 +527,7 @@ namespace Bit.Core.Services
MaxStorageGb = !plan.MaxStorageGb.HasValue ?
(short?)null : (short)(plan.MaxStorageGb.Value + signup.AdditionalStorageGb),
UseGroups = plan.UseGroups,
UseEvents = plan.UseEvents,
UseDirectory = plan.UseDirectory,
UseTotp = plan.UseTotp,
SelfHost = plan.SelfHost,
@ -582,6 +583,7 @@ namespace Bit.Core.Services
MaxStorageGb = _globalSettings.SelfHosted ? 10240 : license.MaxStorageGb, // 10 TB
UseGroups = license.UseGroups,
UseDirectory = license.UseDirectory,
UseEvents = license.UseEvents,
UseTotp = license.UseTotp,
Plan = license.Plan,
SelfHost = license.SelfHost,
@ -744,6 +746,7 @@ namespace Bit.Core.Services
organization.MaxCollections = license.MaxCollections;
organization.UseGroups = license.UseGroups;
organization.UseDirectory = license.UseDirectory;
organization.UseEvents = license.UseEvents;
organization.UseTotp = license.UseTotp;
organization.Plan = license.Plan;
organization.Enabled = license.Enabled;

View File

@ -161,6 +161,7 @@ namespace Bit.Core.Utilities
TrialPeriodDays = 7,
UseGroups = true,
UseDirectory = true,
UseEvents = true,
UseTotp = true,
MaxStorageGb = 1,
SelfHost = true,
@ -181,6 +182,7 @@ namespace Bit.Core.Utilities
TrialPeriodDays = 7,
UseGroups = true,
UseDirectory = true,
UseEvents = true,
UseTotp = true,
MaxStorageGb = 1,
SelfHost = true,

View File

@ -218,5 +218,6 @@
<Build Include="dbo\Stored Procedures\User_BumpAccountRevisionDateByCipherId.sql" />
<Build Include="dbo\Tables\Event.sql" />
<Build Include="dbo\Stored Procedures\Event_Create.sql" />
<Build Include="dbo\Views\EventView.sql" />
</ItemGroup>
</Project>

View File

@ -14,6 +14,7 @@
@MaxCollections SMALLINT,
@UseGroups BIT,
@UseDirectory BIT,
@UseEvents BIT,
@UseTotp BIT,
@SelfHost BIT,
@UsersGetPremium BIT,
@ -48,6 +49,7 @@ BEGIN
[MaxCollections],
[UseGroups],
[UseDirectory],
[UseEvents],
[UseTotp],
[SelfHost],
[UsersGetPremium],
@ -79,6 +81,7 @@ BEGIN
@MaxCollections,
@UseGroups,
@UseDirectory,
@UseEvents,
@UseTotp,
@SelfHost,
@UsersGetPremium,

View File

@ -14,6 +14,7 @@
@MaxCollections SMALLINT,
@UseGroups BIT,
@UseDirectory BIT,
@UseEvents BIT,
@UseTotp BIT,
@SelfHost BIT,
@UsersGetPremium BIT,
@ -48,6 +49,7 @@ BEGIN
[MaxCollections] = @MaxCollections,
[UseGroups] = @UseGroups,
[UseDirectory] = @UseDirectory,
[UseEvents] = @UseEvents,
[UseTotp] = @UseTotp,
[SelfHost] = @SelfHost,
[UsersGetPremium] = @UsersGetPremium,

View File

@ -14,6 +14,7 @@
[MaxCollections] SMALLINT NULL,
[UseGroups] BIT NOT NULL,
[UseDirectory] BIT NOT NULL,
[UseEvents] BIT NOT NULL,
[UseTotp] BIT NOT NULL,
[SelfHost] BIT NOT NULL,
[UsersGetPremium] BIT NOT NULL,

View File

@ -0,0 +1,6 @@
CREATE VIEW [dbo].[EventView]
AS
SELECT
*
FROM
[dbo].[Event]

View File

@ -7,6 +7,7 @@ SELECT
O.[Enabled],
O.[UseGroups],
O.[UseDirectory],
O.[UseEvents],
O.[UseTotp],
O.[SelfHost],
O.[UsersGetPremium],