1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-01 23:31:41 +01:00

Added RevisionDate to User table/domain

This commit is contained in:
Kyle Spearrin 2016-02-21 00:36:08 -05:00
parent 1b3acec905
commit 5d7a0216bf
7 changed files with 26 additions and 14 deletions

View File

@ -41,6 +41,7 @@ namespace Bit.Core.Repositories.SqlServer
cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = user.Email;
cmd.Parameters.Add("@MasterPassword", SqlDbType.NVarChar).Value = user.MasterPassword;
cmd.Parameters.Add("@SecurityStamp", SqlDbType.NVarChar).Value = user.SecurityStamp;
cmd.Parameters.Add("@RevisionDate", SqlDbType.DateTime2).Value = user.RevisionDate;
cmd.ExecuteNonQuery();
}
@ -92,9 +93,9 @@ namespace Bit.Core.Repositories.SqlServer
UPDATE
[dbo].[Folder]
SET
[UserId] = TF.[UserId],
-- Do not update [UserId]
[Name] = TF.[Name],
[CreationDate] = TF.[CreationDate],
-- Do not update TF.[CreationDate]
[RevisionDate] = TF.[RevisionDate]
FROM
[dbo].[Folder] F
@ -106,14 +107,14 @@ namespace Bit.Core.Repositories.SqlServer
UPDATE
[dbo].[Site]
SET
[UserId] = TS.[UserId],
[FolderId] = TS.[FolderId],
-- Do not update [UserId]
-- Do not update [FolderId]
[Name] = TS.[Name],
[Uri] = TS.[Uri],
[Username] = TS.[Username],
[Password] = TS.[Password],
[Notes] = TS.[Notes],
[CreationDate] = TS.[CreationDate],
-- Do not update [CreationDate]
[RevisionDate] = TS.[RevisionDate]
FROM
[dbo].[Site] S

View File

@ -21,6 +21,7 @@ namespace Bit.Core.Repositories.SqlServer.Models
TwoFactorProvider = user.TwoFactorProvider;
AuthenticatorKey = user.AuthenticatorKey;
CreationDate = user.CreationDate;
RevisionDate = user.RevisionDate;
}
public Guid Id { get; set; }
@ -34,6 +35,7 @@ namespace Bit.Core.Repositories.SqlServer.Models
public TwoFactorProvider? TwoFactorProvider { get; set; }
public string AuthenticatorKey { get; set; }
public DateTime CreationDate { get; set; }
public DateTime RevisionDate { get; set; }
public User ToDomain()
{
@ -49,7 +51,8 @@ namespace Bit.Core.Repositories.SqlServer.Models
TwoFactorEnabled = TwoFactorEnabled,
TwoFactorProvider = TwoFactorProvider,
AuthenticatorKey = AuthenticatorKey,
CreationDate = CreationDate
CreationDate = CreationDate,
RevisionDate = RevisionDate
};
}
}

View File

@ -68,9 +68,9 @@
<Build Include="dbo\Tables\Folder.sql" />
<Build Include="dbo\Tables\Site.sql" />
<Build Include="dbo\Tables\User.sql" />
<Build Include="dbo\Views\UserView.sql" />
<Build Include="dbo\Views\FolderView.sql" />
<Build Include="dbo\Views\SiteView.sql" />
<Build Include="dbo\Views\UserView.sql" />
<Build Include="dbo\Stored Procedures\User_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Folder_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Site_ReadById.sql" />

View File

@ -9,7 +9,8 @@
@TwoFactorEnabled BIT,
@TwoFactorProvider TINYINT,
@AuthenticatorKey NVARCHAR(50),
@CreationDate DATETIME2(7)
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
BEGIN
INSERT INTO [dbo].[User]
@ -24,7 +25,8 @@ BEGIN
[TwoFactorEnabled],
[TwoFactorProvider],
[AuthenticatorKey],
[CreationDate]
[CreationDate],
[RevisionDate]
)
VALUES
(
@ -38,6 +40,7 @@ BEGIN
@TwoFactorEnabled,
@TwoFactorProvider,
@AuthenticatorKey,
@CreationDate
@CreationDate,
@RevisionDate
)
END

View File

@ -9,7 +9,8 @@
@TwoFactorEnabled BIT,
@TwoFactorProvider TINYINT,
@AuthenticatorKey NVARCHAR(50),
@CreationDate DATETIME2(7)
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7)
AS
BEGIN
UPDATE
@ -24,7 +25,8 @@ BEGIN
[TwoFactorEnabled] = @TwoFactorEnabled,
[TwoFactorProvider] = TwoFactorProvider,
[AuthenticatorKey] = @AuthenticatorKey,
[CreationDate] = @CreationDate
[CreationDate] = @CreationDate,
[RevisionDate] = @RevisionDate
WHERE
[Id] = @Id
END

View File

@ -2,7 +2,8 @@
@Id UNIQUEIDENTIFIER,
@Email NVARCHAR(50),
@MasterPassword NVARCHAR(300),
@SecurityStamp NVARCHAR(50)
@SecurityStamp NVARCHAR(50),
@RevisionDate DATETIME2(7)
AS
BEGIN
UPDATE
@ -10,7 +11,8 @@ BEGIN
SET
[Email] = @Email,
[MasterPassword] = @MasterPassword,
[SecurityStamp] = @SecurityStamp
[SecurityStamp] = @SecurityStamp,
[RevisionDate] = @RevisionDate
WHERE
[Id] = @Id
END

View File

@ -10,6 +10,7 @@
[TwoFactorProvider] TINYINT NULL,
[AuthenticatorKey] NVARCHAR (50) NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ([Id] ASC)
);