1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

Fix password re-prompt not working in org view (#1296)

* Fix password reprompt not working in org view

* Also fix Cipher_UpdateWithCollections and CipherDetails_CreateWithCollections. Rename migration script
This commit is contained in:
Oscar Hinton
2021-05-04 20:36:35 +02:00
committed by GitHub
parent 179e6aa76b
commit 6ada46f906
11 changed files with 472 additions and 210 deletions

View File

@ -60,7 +60,6 @@ namespace Bit.Core.Models.Api
{
existingCipher.FolderId = string.IsNullOrWhiteSpace(FolderId) ? null : (Guid?)new Guid(FolderId);
existingCipher.Favorite = Favorite;
existingCipher.Reprompt = Reprompt;
ToCipher(existingCipher);
return existingCipher;
}
@ -91,6 +90,8 @@ namespace Bit.Core.Models.Api
throw new ArgumentException("Unsupported type: " + nameof(Type) + ".");
}
existingCipher.Reprompt = Reprompt;
var hasAttachments2 = (Attachments2?.Count ?? 0) > 0;
var hasAttachments = (Attachments?.Count ?? 0) > 0;

View File

@ -63,6 +63,7 @@ namespace Bit.Core.Models.Api
Attachments = AttachmentResponseModel.FromCipher(cipher, globalSettings);
OrganizationUseTotp = orgUseTotp;
DeletedDate = cipher.DeletedDate;
Reprompt = cipher.Reprompt.GetValueOrDefault(CipherRepromptType.None);
}
public string Id { get; set; }
@ -81,6 +82,7 @@ namespace Bit.Core.Models.Api
public bool OrganizationUseTotp { get; set; }
public DateTime RevisionDate { get; set; }
public DateTime? DeletedDate { get; set; }
public CipherRepromptType Reprompt { get; set; }
}
public class CipherResponseModel : CipherMiniResponseModel
@ -92,14 +94,12 @@ namespace Bit.Core.Models.Api
Favorite = cipher.Favorite;
Edit = cipher.Edit;
ViewPassword = cipher.ViewPassword;
Reprompt = cipher.Reprompt.GetValueOrDefault(CipherRepromptType.None);
}
public string FolderId { get; set; }
public bool Favorite { get; set; }
public bool Edit { get; set; }
public bool ViewPassword { get; set; }
public CipherRepromptType Reprompt { get; set; }
}
public class CipherDetailsResponseModel : CipherResponseModel

View File

@ -668,6 +668,8 @@ namespace Bit.Core.Repositories.SqlServer
ciphersTable.Columns.Add(revisionDateColumn);
var deletedDateColumn = new DataColumn(nameof(c.DeletedDate), typeof(DateTime));
ciphersTable.Columns.Add(deletedDateColumn);
var repromptColumn = new DataColumn(nameof(c.Reprompt), typeof(short));
ciphersTable.Columns.Add(repromptColumn);
foreach (DataColumn col in ciphersTable.Columns)
{
@ -693,6 +695,7 @@ namespace Bit.Core.Repositories.SqlServer
row[creationDateColumn] = cipher.CreationDate;
row[revisionDateColumn] = cipher.RevisionDate;
row[deletedDateColumn] = cipher.DeletedDate.HasValue ? (object)cipher.DeletedDate : DBNull.Value;
row[repromptColumn] = cipher.Reprompt;
ciphersTable.Rows.Add(row);
}

View File

@ -15,6 +15,7 @@
@ViewPassword BIT, -- not used
@OrganizationUseTotp BIT, -- not used
@DeletedDate DATETIME2(7),
@Reprompt TINYINT,
@CollectionIds AS [dbo].[GuidIdArray] READONLY
AS
BEGIN
@ -22,7 +23,7 @@ BEGIN
EXEC [dbo].[CipherDetails_Create] @Id, @UserId, @OrganizationId, @Type, @Data, @Favorites, @Folders,
@Attachments, @CreationDate, @RevisionDate, @FolderId, @Favorite, @Edit, @ViewPassword,
@OrganizationUseTotp, @DeletedDate
@OrganizationUseTotp, @DeletedDate, @Reprompt
DECLARE @UpdateCollectionsSuccess INT
EXEC @UpdateCollectionsSuccess = [dbo].[Cipher_UpdateCollections] @Id, @UserId, @OrganizationId, @CollectionIds

View File

@ -9,7 +9,8 @@
@Attachments NVARCHAR(MAX),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7),
@DeletedDate DATETIME2(7)
@DeletedDate DATETIME2(7),
@Reprompt TINYINT
AS
BEGIN
SET NOCOUNT ON
@ -26,7 +27,8 @@ BEGIN
[Attachments],
[CreationDate],
[RevisionDate],
[DeletedDate]
[DeletedDate],
[Reprompt]
)
VALUES
(
@ -40,7 +42,8 @@ BEGIN
@Attachments,
@CreationDate,
@RevisionDate,
@DeletedDate
@DeletedDate,
@Reprompt
)
IF @OrganizationId IS NOT NULL

View File

@ -10,13 +10,14 @@
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7),
@DeletedDate DATETIME2(7),
@Reprompt TINYINT,
@CollectionIds AS [dbo].[GuidIdArray] READONLY
AS
BEGIN
SET NOCOUNT ON
EXEC [dbo].[Cipher_Create] @Id, @UserId, @OrganizationId, @Type, @Data, @Favorites, @Folders,
@Attachments, @CreationDate, @RevisionDate, @DeletedDate
@Attachments, @CreationDate, @RevisionDate, @DeletedDate, @Reprompt
DECLARE @UpdateCollectionsSuccess INT
EXEC @UpdateCollectionsSuccess = [dbo].[Cipher_UpdateCollections] @Id, @UserId, @OrganizationId, @CollectionIds

View File

@ -9,7 +9,8 @@
@Attachments NVARCHAR(MAX),
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7),
@DeletedDate DATETIME2(7)
@DeletedDate DATETIME2(7),
@Reprompt TINYINT
AS
BEGIN
SET NOCOUNT ON
@ -26,7 +27,8 @@ BEGIN
[Attachments] = @Attachments,
[CreationDate] = @CreationDate,
[RevisionDate] = @RevisionDate,
[DeletedDate] = @DeletedDate
[DeletedDate] = @DeletedDate,
[Reprompt] = @Reprompt
WHERE
[Id] = @Id

View File

@ -10,6 +10,7 @@
@CreationDate DATETIME2(7),
@RevisionDate DATETIME2(7),
@DeletedDate DATETIME2(7),
@Reprompt TINYINT,
@CollectionIds AS [dbo].[GuidIdArray] READONLY
AS
BEGIN