1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00

Transition reference id to data (#828)

* Transition reference id to data

* field length and request model updates
This commit is contained in:
Chad Scharf 2020-07-20 15:19:46 -04:00 committed by GitHub
parent 036b402e9f
commit 83e9468502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 510 additions and 23 deletions

View File

@ -2,7 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Models.Business;
using Bit.Core.Models.Table; using Bit.Core.Models.Table;
using Newtonsoft.Json;
namespace Bit.Core.Models.Api namespace Bit.Core.Models.Api
{ {
@ -25,7 +27,7 @@ namespace Bit.Core.Models.Api
public Guid? OrganizationUserId { get; set; } public Guid? OrganizationUserId { get; set; }
public KdfType? Kdf { get; set; } public KdfType? Kdf { get; set; }
public int? KdfIterations { get; set; } public int? KdfIterations { get; set; }
public string ReferenceId { get; set; } public Dictionary<string, object> ReferenceData { get; set; }
public User ToUser() public User ToUser()
{ {
@ -36,9 +38,13 @@ namespace Bit.Core.Models.Api
MasterPasswordHint = MasterPasswordHint, MasterPasswordHint = MasterPasswordHint,
Kdf = Kdf.GetValueOrDefault(KdfType.PBKDF2_SHA256), Kdf = Kdf.GetValueOrDefault(KdfType.PBKDF2_SHA256),
KdfIterations = KdfIterations.GetValueOrDefault(5000), KdfIterations = KdfIterations.GetValueOrDefault(5000),
ReferenceId = ReferenceId,
}; };
if (ReferenceData != null)
{
user.ReferenceData = JsonConvert.SerializeObject(ReferenceData);
}
if (Key != null) if (Key != null)
{ {
user.Key = Key; user.Key = Key;

View File

@ -18,7 +18,7 @@ namespace Bit.Core.Models.Business
{ {
Source = source.IsUser() ? ReferenceEventSource.User : ReferenceEventSource.Organization; Source = source.IsUser() ? ReferenceEventSource.User : ReferenceEventSource.Organization;
Id = source.Id; Id = source.Id;
ReferenceId = source.ReferenceId; ReferenceData = source.ReferenceData;
} }
} }
@ -30,7 +30,7 @@ namespace Bit.Core.Models.Business
public Guid Id { get; set; } public Guid Id { get; set; }
public string ReferenceId { get; set; } public string ReferenceData { get; set; }
public DateTime EventDate { get; set; } = DateTime.UtcNow; public DateTime EventDate { get; set; } = DateTime.UtcNow;

View File

@ -0,0 +1,16 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Bit.Core.Models.Business
{
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class ReferenceEventData
{
public string Id { get; set; }
public string Layout { get; set; }
public string Flow { get; set; }
}
}

View File

@ -5,7 +5,7 @@ namespace Bit.Core.Models
public interface IReferenceable public interface IReferenceable
{ {
Guid Id { get; set; } Guid Id { get; set; }
string ReferenceId { get; set; } string ReferenceData { get; set; }
bool IsUser(); bool IsUser();
} }
} }

View File

@ -39,7 +39,7 @@ namespace Bit.Core.Models.Table
public GatewayType? Gateway { get; set; } public GatewayType? Gateway { get; set; }
public string GatewayCustomerId { get; set; } public string GatewayCustomerId { get; set; }
public string GatewaySubscriptionId { get; set; } public string GatewaySubscriptionId { get; set; }
public string ReferenceId { get; set; } public string ReferenceData { get; set; }
public bool Enabled { get; set; } = true; public bool Enabled { get; set; } = true;
public string LicenseKey { get; set; } public string LicenseKey { get; set; }
public string ApiKey { get; set; } public string ApiKey { get; set; }

View File

@ -37,7 +37,7 @@ namespace Bit.Core.Models.Table
public GatewayType? Gateway { get; set; } public GatewayType? Gateway { get; set; }
public string GatewayCustomerId { get; set; } public string GatewayCustomerId { get; set; }
public string GatewaySubscriptionId { get; set; } public string GatewaySubscriptionId { get; set; }
public string ReferenceId { get; set; } public string ReferenceData { get; set; }
public string LicenseKey { get; set; } public string LicenseKey { get; set; }
public KdfType Kdf { get; set; } = KdfType.PBKDF2_SHA256; public KdfType Kdf { get; set; } = KdfType.PBKDF2_SHA256;
public int KdfIterations { get; set; } = 5000; public int KdfIterations { get; set; } = 5000;

View File

@ -30,9 +30,9 @@ namespace Bit.Core.Services
private async Task SendMessageAsync(ReferenceEvent referenceEvent) private async Task SendMessageAsync(ReferenceEvent referenceEvent)
{ {
if (_globalSettings.SelfHosted || string.IsNullOrWhiteSpace(referenceEvent.ReferenceId)) if (_globalSettings.SelfHosted)
{ {
// Ignore for self-hosted, OR, where there is no ReferenceId // Ignore for self-hosted
return; return;
} }
try try

View File

@ -514,7 +514,7 @@ namespace Bit.Core.Services
UsersGetPremium = plan.UsersGetPremium || signup.PremiumAccessAddon, UsersGetPremium = plan.UsersGetPremium || signup.PremiumAccessAddon,
Plan = plan.Name, Plan = plan.Name,
Gateway = null, Gateway = null,
ReferenceId = signup.Owner.ReferenceId, ReferenceData = signup.Owner.ReferenceData,
Enabled = true, Enabled = true,
LicenseKey = CoreHelpers.SecureRandomString(20), LicenseKey = CoreHelpers.SecureRandomString(20),
ApiKey = CoreHelpers.SecureRandomString(30), ApiKey = CoreHelpers.SecureRandomString(30),
@ -598,7 +598,7 @@ namespace Bit.Core.Services
Gateway = null, Gateway = null,
GatewayCustomerId = null, GatewayCustomerId = null,
GatewaySubscriptionId = null, GatewaySubscriptionId = null,
ReferenceId = owner.ReferenceId, ReferenceData = owner.ReferenceData,
Enabled = license.Enabled, Enabled = license.Enabled,
ExpirationDate = license.Expires, ExpirationDate = license.Expires,
LicenseKey = license.LicenseKey, LicenseKey = license.LicenseKey,

View File

@ -27,7 +27,7 @@
@Gateway TINYINT, @Gateway TINYINT,
@GatewayCustomerId VARCHAR(50), @GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50), @GatewaySubscriptionId VARCHAR(50),
@ReferenceId VARCHAR(50), @ReferenceData VARCHAR(MAX),
@Enabled BIT, @Enabled BIT,
@LicenseKey VARCHAR(100), @LicenseKey VARCHAR(100),
@ApiKey VARCHAR(30), @ApiKey VARCHAR(30),
@ -69,7 +69,7 @@ BEGIN
[Gateway], [Gateway],
[GatewayCustomerId], [GatewayCustomerId],
[GatewaySubscriptionId], [GatewaySubscriptionId],
[ReferenceId], [ReferenceData],
[Enabled], [Enabled],
[LicenseKey], [LicenseKey],
[ApiKey], [ApiKey],
@ -108,7 +108,7 @@ BEGIN
@Gateway, @Gateway,
@GatewayCustomerId, @GatewayCustomerId,
@GatewaySubscriptionId, @GatewaySubscriptionId,
@ReferenceId, @ReferenceData,
@Enabled, @Enabled,
@LicenseKey, @LicenseKey,
@ApiKey, @ApiKey,

View File

@ -27,7 +27,7 @@
@Gateway TINYINT, @Gateway TINYINT,
@GatewayCustomerId VARCHAR(50), @GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50), @GatewaySubscriptionId VARCHAR(50),
@ReferenceId VARCHAR(50), @ReferenceData VARCHAR(MAX),
@Enabled BIT, @Enabled BIT,
@LicenseKey VARCHAR(100), @LicenseKey VARCHAR(100),
@ApiKey VARCHAR(30), @ApiKey VARCHAR(30),
@ -69,7 +69,7 @@ BEGIN
[Gateway] = @Gateway, [Gateway] = @Gateway,
[GatewayCustomerId] = @GatewayCustomerId, [GatewayCustomerId] = @GatewayCustomerId,
[GatewaySubscriptionId] = @GatewaySubscriptionId, [GatewaySubscriptionId] = @GatewaySubscriptionId,
[ReferenceId] = @ReferenceId, [ReferenceData] = @ReferenceData,
[Enabled] = @Enabled, [Enabled] = @Enabled,
[LicenseKey] = @LicenseKey, [LicenseKey] = @LicenseKey,
[ApiKey] = @ApiKey, [ApiKey] = @ApiKey,

View File

@ -23,7 +23,7 @@
@Gateway TINYINT, @Gateway TINYINT,
@GatewayCustomerId VARCHAR(50), @GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50), @GatewaySubscriptionId VARCHAR(50),
@ReferenceId VARCHAR(50), @ReferenceData VARCHAR(MAX),
@LicenseKey VARCHAR(100), @LicenseKey VARCHAR(100),
@Kdf TINYINT, @Kdf TINYINT,
@KdfIterations INT, @KdfIterations INT,
@ -59,7 +59,7 @@ BEGIN
[Gateway], [Gateway],
[GatewayCustomerId], [GatewayCustomerId],
[GatewaySubscriptionId], [GatewaySubscriptionId],
[ReferenceId], [ReferenceData],
[LicenseKey], [LicenseKey],
[Kdf], [Kdf],
[KdfIterations], [KdfIterations],
@ -92,7 +92,7 @@ BEGIN
@Gateway, @Gateway,
@GatewayCustomerId, @GatewayCustomerId,
@GatewaySubscriptionId, @GatewaySubscriptionId,
@ReferenceId, @ReferenceData,
@LicenseKey, @LicenseKey,
@Kdf, @Kdf,
@KdfIterations, @KdfIterations,

View File

@ -23,7 +23,7 @@
@Gateway TINYINT, @Gateway TINYINT,
@GatewayCustomerId VARCHAR(50), @GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50), @GatewaySubscriptionId VARCHAR(50),
@ReferenceId VARCHAR(50), @ReferenceData VARCHAR(MAX),
@LicenseKey VARCHAR(100), @LicenseKey VARCHAR(100),
@Kdf TINYINT, @Kdf TINYINT,
@KdfIterations INT, @KdfIterations INT,
@ -59,7 +59,7 @@ BEGIN
[Gateway] = @Gateway, [Gateway] = @Gateway,
[GatewayCustomerId] = @GatewayCustomerId, [GatewayCustomerId] = @GatewayCustomerId,
[GatewaySubscriptionId] = @GatewaySubscriptionId, [GatewaySubscriptionId] = @GatewaySubscriptionId,
[ReferenceId] = @ReferenceId, [ReferenceData] = @ReferenceData,
[LicenseKey] = @LicenseKey, [LicenseKey] = @LicenseKey,
[Kdf] = @Kdf, [Kdf] = @Kdf,
[KdfIterations] = @KdfIterations, [KdfIterations] = @KdfIterations,

View File

@ -27,7 +27,7 @@
[Gateway] TINYINT NULL, [Gateway] TINYINT NULL,
[GatewayCustomerId] VARCHAR (50) NULL, [GatewayCustomerId] VARCHAR (50) NULL,
[GatewaySubscriptionId] VARCHAR (50) NULL, [GatewaySubscriptionId] VARCHAR (50) NULL,
[ReferenceId] NVARCHAR (50) NULL, [ReferenceData] NVARCHAR (MAX) NULL,
[Enabled] BIT NOT NULL, [Enabled] BIT NOT NULL,
[LicenseKey] VARCHAR (100) NULL, [LicenseKey] VARCHAR (100) NULL,
[ApiKey] VARCHAR (30) NOT NULL, [ApiKey] VARCHAR (30) NOT NULL,

View File

@ -23,7 +23,7 @@
[Gateway] TINYINT NULL, [Gateway] TINYINT NULL,
[GatewayCustomerId] VARCHAR (50) NULL, [GatewayCustomerId] VARCHAR (50) NULL,
[GatewaySubscriptionId] VARCHAR (50) NULL, [GatewaySubscriptionId] VARCHAR (50) NULL,
[ReferenceId] NVARCHAR (50) NULL, [ReferenceData] NVARCHAR (MAX) NULL,
[LicenseKey] VARCHAR (100) NULL, [LicenseKey] VARCHAR (100) NULL,
[Kdf] TINYINT NOT NULL, [Kdf] TINYINT NOT NULL,
[KdfIterations] INT NOT NULL, [KdfIterations] INT NOT NULL,

View File

@ -0,0 +1,465 @@
IF COL_LENGTH('[dbo].[User]', 'ReferenceId') IS NOT NULL
BEGIN
ALTER TABLE [dbo].[User]
DROP COLUMN [ReferenceId];
END
GO
IF COL_LENGTH('[dbo].[Organization]', 'ReferenceId') IS NOT NULL
BEGIN
ALTER TABLE [dbo].[Organization]
DROP COLUMN [ReferenceId];
END
GO
IF COL_LENGTH('[dbo].[User]', 'ReferenceData') IS NULL
BEGIN
ALTER TABLE
[dbo].[User]
ADD
[ReferenceData] NVARCHAR (MAX) NULL;
END
GO
IF COL_LENGTH('[dbo].[Organization]', 'ReferenceData') IS NULL
BEGIN
ALTER TABLE
[dbo].[Organization]
ADD
[ReferenceData] NVARCHAR (MAX) NULL;
END
GO
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'UserView')
BEGIN
DROP VIEW [dbo].[UserView];
END
GO
CREATE VIEW [dbo].[UserView]
AS
SELECT
*
FROM
[dbo].[User]
GO
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'OrganizationView')
BEGIN
DROP VIEW [dbo].[OrganizationView];
END
GO
CREATE VIEW [dbo].[OrganizationView]
AS
SELECT
*
FROM
[dbo].[Organization]
GO
IF OBJECT_ID('[dbo].[User_Create]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[User_Create]
END
GO
CREATE PROCEDURE [dbo].[User_Create]
@Id UNIQUEIDENTIFIER,
@Name NVARCHAR(50),
@Email NVARCHAR(50),
@EmailVerified BIT,
@MasterPassword NVARCHAR(300),
@MasterPasswordHint NVARCHAR(50),
@Culture NVARCHAR(10),
@SecurityStamp NVARCHAR(50),
@TwoFactorProviders NVARCHAR(MAX),
@TwoFactorRecoveryCode NVARCHAR(32),
@EquivalentDomains NVARCHAR(MAX),
@ExcludedGlobalEquivalentDomains NVARCHAR(MAX),
@AccountRevisionDate DATETIME2(7),
@Key NVARCHAR(MAX),
@PublicKey NVARCHAR(MAX),
@PrivateKey NVARCHAR(MAX),
@Premium BIT,
@PremiumExpirationDate DATETIME2(7),
@RenewalReminderDate DATETIME2(7),
@Storage BIGINT,
@MaxStorageGb SMALLINT,
@Gateway TINYINT,
@GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50),
@ReferenceData VARCHAR(MAX),
@LicenseKey VARCHAR(100),
@Kdf TINYINT,
@KdfIterations INT,
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [dbo].[User]
(
[Id],
[Name],
[Email],
[EmailVerified],
[MasterPassword],
[MasterPasswordHint],
[Culture],
[SecurityStamp],
[TwoFactorProviders],
[TwoFactorRecoveryCode],
[EquivalentDomains],
[ExcludedGlobalEquivalentDomains],
[AccountRevisionDate],
[Key],
[PublicKey],
[PrivateKey],
[Premium],
[PremiumExpirationDate],
[RenewalReminderDate],
[Storage],
[MaxStorageGb],
[Gateway],
[GatewayCustomerId],
[GatewaySubscriptionId],
[ReferenceData],
[LicenseKey],
[Kdf],
[KdfIterations],
[CreationDate],
[RevisionDate]
)
VALUES
(
@Id,
@Name,
@Email,
@EmailVerified,
@MasterPassword,
@MasterPasswordHint,
@Culture,
@SecurityStamp,
@TwoFactorProviders,
@TwoFactorRecoveryCode,
@EquivalentDomains,
@ExcludedGlobalEquivalentDomains,
@AccountRevisionDate,
@Key,
@PublicKey,
@PrivateKey,
@Premium,
@PremiumExpirationDate,
@RenewalReminderDate,
@Storage,
@MaxStorageGb,
@Gateway,
@GatewayCustomerId,
@GatewaySubscriptionId,
@ReferenceData,
@LicenseKey,
@Kdf,
@KdfIterations,
@CreationDate,
@RevisionDate
)
END
GO
IF OBJECT_ID('[dbo].[User_Update]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[User_Update]
END
GO
CREATE PROCEDURE [dbo].[User_Update]
@Id UNIQUEIDENTIFIER,
@Name NVARCHAR(50),
@Email NVARCHAR(50),
@EmailVerified BIT,
@MasterPassword NVARCHAR(300),
@MasterPasswordHint NVARCHAR(50),
@Culture NVARCHAR(10),
@SecurityStamp NVARCHAR(50),
@TwoFactorProviders NVARCHAR(MAX),
@TwoFactorRecoveryCode NVARCHAR(32),
@EquivalentDomains NVARCHAR(MAX),
@ExcludedGlobalEquivalentDomains NVARCHAR(MAX),
@AccountRevisionDate DATETIME2(7),
@Key NVARCHAR(MAX),
@PublicKey NVARCHAR(MAX),
@PrivateKey NVARCHAR(MAX),
@Premium BIT,
@PremiumExpirationDate DATETIME2(7),
@RenewalReminderDate DATETIME2(7),
@Storage BIGINT,
@MaxStorageGb SMALLINT,
@Gateway TINYINT,
@GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50),
@ReferenceData VARCHAR(MAX),
@LicenseKey VARCHAR(100),
@Kdf TINYINT,
@KdfIterations INT,
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
UPDATE
[dbo].[User]
SET
[Name] = @Name,
[Email] = @Email,
[EmailVerified] = @EmailVerified,
[MasterPassword] = @MasterPassword,
[MasterPasswordHint] = @MasterPasswordHint,
[Culture] = @Culture,
[SecurityStamp] = @SecurityStamp,
[TwoFactorProviders] = @TwoFactorProviders,
[TwoFactorRecoveryCode] = @TwoFactorRecoveryCode,
[EquivalentDomains] = @EquivalentDomains,
[ExcludedGlobalEquivalentDomains] = @ExcludedGlobalEquivalentDomains,
[AccountRevisionDate] = @AccountRevisionDate,
[Key] = @Key,
[PublicKey] = @PublicKey,
[PrivateKey] = @PrivateKey,
[Premium] = @Premium,
[PremiumExpirationDate] = @PremiumExpirationDate,
[RenewalReminderDate] = @RenewalReminderDate,
[Storage] = @Storage,
[MaxStorageGb] = @MaxStorageGb,
[Gateway] = @Gateway,
[GatewayCustomerId] = @GatewayCustomerId,
[GatewaySubscriptionId] = @GatewaySubscriptionId,
[ReferenceData] = @ReferenceData,
[LicenseKey] = @LicenseKey,
[Kdf] = @Kdf,
[KdfIterations] = @KdfIterations,
[CreationDate] = @CreationDate,
[RevisionDate] = @RevisionDate
WHERE
[Id] = @Id
END
GO
IF OBJECT_ID('[dbo].[Organization_Create]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Organization_Create]
END
GO
CREATE PROCEDURE [dbo].[Organization_Create]
@Id UNIQUEIDENTIFIER,
@Identifier NVARCHAR(50),
@Name NVARCHAR(50),
@BusinessName NVARCHAR(50),
@BusinessAddress1 NVARCHAR(50),
@BusinessAddress2 NVARCHAR(50),
@BusinessAddress3 NVARCHAR(50),
@BusinessCountry VARCHAR(2),
@BusinessTaxNumber NVARCHAR(30),
@BillingEmail NVARCHAR(50),
@Plan NVARCHAR(50),
@PlanType TINYINT,
@Seats SMALLINT,
@MaxCollections SMALLINT,
@UsePolicies BIT,
@UseGroups BIT,
@UseDirectory BIT,
@UseEvents BIT,
@UseTotp BIT,
@Use2fa BIT,
@UseApi BIT,
@SelfHost BIT,
@UsersGetPremium BIT,
@Storage BIGINT,
@MaxStorageGb SMALLINT,
@Gateway TINYINT,
@GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50),
@ReferenceData VARCHAR(MAX),
@Enabled BIT,
@LicenseKey VARCHAR(100),
@ApiKey VARCHAR(30),
@TwoFactorProviders NVARCHAR(MAX),
@ExpirationDate DATETIME2(7),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [dbo].[Organization]
(
[Id],
[Identifier],
[Name],
[BusinessName],
[BusinessAddress1],
[BusinessAddress2],
[BusinessAddress3],
[BusinessCountry],
[BusinessTaxNumber],
[BillingEmail],
[Plan],
[PlanType],
[Seats],
[MaxCollections],
[UsePolicies],
[UseGroups],
[UseDirectory],
[UseEvents],
[UseTotp],
[Use2fa],
[UseApi],
[SelfHost],
[UsersGetPremium],
[Storage],
[MaxStorageGb],
[Gateway],
[GatewayCustomerId],
[GatewaySubscriptionId],
[ReferenceData],
[Enabled],
[LicenseKey],
[ApiKey],
[TwoFactorProviders],
[ExpirationDate],
[CreationDate],
[RevisionDate]
)
VALUES
(
@Id,
@Identifier,
@Name,
@BusinessName,
@BusinessAddress1,
@BusinessAddress2,
@BusinessAddress3,
@BusinessCountry,
@BusinessTaxNumber,
@BillingEmail,
@Plan,
@PlanType,
@Seats,
@MaxCollections,
@UsePolicies,
@UseGroups,
@UseDirectory,
@UseEvents,
@UseTotp,
@Use2fa,
@UseApi,
@SelfHost,
@UsersGetPremium,
@Storage,
@MaxStorageGb,
@Gateway,
@GatewayCustomerId,
@GatewaySubscriptionId,
@ReferenceData,
@Enabled,
@LicenseKey,
@ApiKey,
@TwoFactorProviders,
@ExpirationDate,
@CreationDate,
@RevisionDate
)
END
GO
IF OBJECT_ID('[dbo].[Organization_Update]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Organization_Update]
END
GO
CREATE PROCEDURE [dbo].[Organization_Update]
@Id UNIQUEIDENTIFIER,
@Identifier NVARCHAR(50),
@Name NVARCHAR(50),
@BusinessName NVARCHAR(50),
@BusinessAddress1 NVARCHAR(50),
@BusinessAddress2 NVARCHAR(50),
@BusinessAddress3 NVARCHAR(50),
@BusinessCountry VARCHAR(2),
@BusinessTaxNumber NVARCHAR(30),
@BillingEmail NVARCHAR(50),
@Plan NVARCHAR(50),
@PlanType TINYINT,
@Seats SMALLINT,
@MaxCollections SMALLINT,
@UsePolicies BIT,
@UseGroups BIT,
@UseDirectory BIT,
@UseEvents BIT,
@UseTotp BIT,
@Use2fa BIT,
@UseApi BIT,
@SelfHost BIT,
@UsersGetPremium BIT,
@Storage BIGINT,
@MaxStorageGb SMALLINT,
@Gateway TINYINT,
@GatewayCustomerId VARCHAR(50),
@GatewaySubscriptionId VARCHAR(50),
@ReferenceData VARCHAR(MAX),
@Enabled BIT,
@LicenseKey VARCHAR(100),
@ApiKey VARCHAR(30),
@TwoFactorProviders NVARCHAR(MAX),
@ExpirationDate DATETIME2(7),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
UPDATE
[dbo].[Organization]
SET
[Identifier] = @Identifier,
[Name] = @Name,
[BusinessName] = @BusinessName,
[BusinessAddress1] = @BusinessAddress1,
[BusinessAddress2] = @BusinessAddress2,
[BusinessAddress3] = @BusinessAddress3,
[BusinessCountry] = @BusinessCountry,
[BusinessTaxNumber] = @BusinessTaxNumber,
[BillingEmail] = @BillingEmail,
[Plan] = @Plan,
[PlanType] = @PlanType,
[Seats] = @Seats,
[MaxCollections] = @MaxCollections,
[UsePolicies] = @UsePolicies,
[UseGroups] = @UseGroups,
[UseDirectory] = @UseDirectory,
[UseEvents] = @UseEvents,
[UseTotp] = @UseTotp,
[Use2fa] = @Use2fa,
[UseApi] = @UseApi,
[SelfHost] = @SelfHost,
[UsersGetPremium] = @UsersGetPremium,
[Storage] = @Storage,
[MaxStorageGb] = @MaxStorageGb,
[Gateway] = @Gateway,
[GatewayCustomerId] = @GatewayCustomerId,
[GatewaySubscriptionId] = @GatewaySubscriptionId,
[ReferenceData] = @ReferenceData,
[Enabled] = @Enabled,
[LicenseKey] = @LicenseKey,
[ApiKey] = @ApiKey,
[TwoFactorProviders] = @TwoFactorProviders,
[ExpirationDate] = @ExpirationDate,
[CreationDate] = @CreationDate,
[RevisionDate] = @RevisionDate
WHERE
[Id] = @Id
END
GO