1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

AccountRevisionDate to track changes for a user account. Managed via triggers.

This commit is contained in:
Kyle Spearrin 2017-01-14 09:42:07 -05:00
parent 1b30a27990
commit fd961dfdf6
6 changed files with 35 additions and 0 deletions

View File

@ -102,5 +102,6 @@
<Build Include="dbo\Stored Procedures\Grant_ReadByKey.sql" />
<Build Include="dbo\Stored Procedures\Grant_ReadBySubjectId.sql" />
<Build Include="dbo\Stored Procedures\Grant_Save.sql" />
<Build Include="dbo\Stored Procedures\User_ReadAccountRevisionDateById.sql" />
</ItemGroup>
</Project>

View File

@ -13,6 +13,7 @@
@TwoFactorRecoveryCode NVARCHAR(32),
@EquivalentDomains NVARCHAR(MAX),
@ExcludedGlobalEquivalentDomains NVARCHAR(MAX),
@AccountRevisionDate DATETIME2(7),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
@ -35,6 +36,7 @@ BEGIN
[TwoFactorRecoveryCode],
[EquivalentDomains],
[ExcludedGlobalEquivalentDomains],
[AccountRevisionDate],
[CreationDate],
[RevisionDate]
)
@ -54,6 +56,7 @@ BEGIN
@TwoFactorRecoveryCode,
@EquivalentDomains,
@ExcludedGlobalEquivalentDomains,
@AccountRevisionDate,
@CreationDate,
@RevisionDate
)

View File

@ -0,0 +1,13 @@
CREATE PROCEDURE [dbo].[User_ReadAccountRevisionDateById]
@Id UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
SELECT
[AccountRevisionDate]
FROM
[dbo].[User]
WHERE
[Id] = @Id
END

View File

@ -13,6 +13,7 @@
@TwoFactorRecoveryCode NVARCHAR(32),
@EquivalentDomains NVARCHAR(MAX),
@ExcludedGlobalEquivalentDomains NVARCHAR(MAX),
@AccountRevisionDate DATETIME2(7),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
@ -35,6 +36,7 @@ BEGIN
[TwoFactorRecoveryCode] = @TwoFactorRecoveryCode,
[EquivalentDomains] = @EquivalentDomains,
[ExcludedGlobalEquivalentDomains] = @ExcludedGlobalEquivalentDomains,
[AccountRevisionDate] = @AccountRevisionDate,
[CreationDate] = @CreationDate,
[RevisionDate] = @RevisionDate
WHERE

View File

@ -42,6 +42,11 @@ BEGIN
[CreationDate]
FROM
INSERTED
UPDATE
[User]
SET
[AccountRevisionDate] = GETUTCDATE()
END
GO
CREATE TRIGGER [dbo].[Cipher_Updated]
@ -67,6 +72,11 @@ BEGIN
[RevisionDate]
FROM
INSERTED
UPDATE
[User]
SET
[AccountRevisionDate] = GETUTCDATE()
END
GO
CREATE TRIGGER [dbo].[Cipher_Deleted]
@ -92,4 +102,9 @@ BEGIN
GETUTCDATE()
FROM
DELETED
UPDATE
[User]
SET
[AccountRevisionDate] = GETUTCDATE()
END

View File

@ -13,6 +13,7 @@
[TwoFactorRecoveryCode] NVARCHAR (32) NULL,
[EquivalentDomains] NVARCHAR (MAX) NULL,
[ExcludedGlobalEquivalentDomains] NVARCHAR (MAX) NULL,
[AccountRevisionDate] DATETIME2 (7) NOT NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([Id] ASC)