From 908e1504afc05447375ce56e7c9dea70dc23783c Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Wed, 7 Jul 2021 20:21:52 +1000 Subject: [PATCH] Fix bulk fingerprints (#1442) * Fix fingerprint phrases in bulk confirm modal * Fix indentation --- .../OrganizationUsersController.cs | 2 +- .../Response/OrganizationUserResponseModel.cs | 7 +++-- .../Models/Data/OrganizationUserPublicKey.cs | 1 + ...er_ReadPublicKeysByOrganizationUserIds.sql | 1 + .../DbScripts/2021-05-18_00_BulkConfirm.sql | 4 +-- .../2021-07-07_00_FixBulkConfirm.sql | 26 +++++++++++++++++++ 6 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 util/Migrator/DbScripts/2021-07-07_00_FixBulkConfirm.sql diff --git a/src/Api/Controllers/OrganizationUsersController.cs b/src/Api/Controllers/OrganizationUsersController.cs index d2f9117621..1d00dc34cd 100644 --- a/src/Api/Controllers/OrganizationUsersController.cs +++ b/src/Api/Controllers/OrganizationUsersController.cs @@ -219,7 +219,7 @@ namespace Bit.Api.Controllers } var result = await _organizationUserRepository.GetManyPublicKeysByOrganizationUserAsync(orgGuidId, model.Ids); - var responses = result.Select(r => new OrganizationUserPublicKeyResponseModel(r.Id, r.PublicKey)).ToList(); + var responses = result.Select(r => new OrganizationUserPublicKeyResponseModel(r.Id, r.UserId, r.PublicKey)).ToList(); return new ListResponseModel(responses); } diff --git a/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs b/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs index 6395d7a5b3..14b0c50e5a 100644 --- a/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs +++ b/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs @@ -111,14 +111,17 @@ namespace Bit.Core.Models.Api public class OrganizationUserPublicKeyResponseModel : ResponseModel { - public OrganizationUserPublicKeyResponseModel(Guid id, string key, - string obj = "organizationUserPublicKeyResponseModel") : base(obj) + public OrganizationUserPublicKeyResponseModel(Guid id, Guid userId, + string key, string obj = "organizationUserPublicKeyResponseModel") : + base(obj) { Id = id; + UserId = userId; Key = key; } public Guid Id { get; set; } + public Guid UserId { get; set; } public string Key { get; set; } } diff --git a/src/Core/Models/Data/OrganizationUserPublicKey.cs b/src/Core/Models/Data/OrganizationUserPublicKey.cs index 004a487684..8357845558 100644 --- a/src/Core/Models/Data/OrganizationUserPublicKey.cs +++ b/src/Core/Models/Data/OrganizationUserPublicKey.cs @@ -5,6 +5,7 @@ namespace Bit.Core.Models.Data public class OrganizationUserPublicKey { public Guid Id { get; set; } + public Guid UserId { get; set; } public string PublicKey { get; set; } } } diff --git a/src/Sql/dbo/Stored Procedures/User_ReadPublicKeysByOrganizationUserIds.sql b/src/Sql/dbo/Stored Procedures/User_ReadPublicKeysByOrganizationUserIds.sql index db263e0f54..da0ff54290 100644 --- a/src/Sql/dbo/Stored Procedures/User_ReadPublicKeysByOrganizationUserIds.sql +++ b/src/Sql/dbo/Stored Procedures/User_ReadPublicKeysByOrganizationUserIds.sql @@ -7,6 +7,7 @@ BEGIN SELECT OU.[Id], + OU.[UserId], U.[PublicKey] FROM @OrganizationUserIds OUIDs diff --git a/util/Migrator/DbScripts/2021-05-18_00_BulkConfirm.sql b/util/Migrator/DbScripts/2021-05-18_00_BulkConfirm.sql index 0f1e2f570d..70f992dc08 100644 --- a/util/Migrator/DbScripts/2021-05-18_00_BulkConfirm.sql +++ b/util/Migrator/DbScripts/2021-05-18_00_BulkConfirm.sql @@ -42,9 +42,9 @@ BEGIN U.[PublicKey] FROM @OrganizationUserIds OUIDs - INNER JOIN + INNER JOIN [dbo].[OrganizationUser] OU ON OUIDs.Id = OU.Id AND OU.[Status] = 1 -- Accepted - INNER JOIN + INNER JOIN [dbo].[User] U ON OU.UserId = U.Id WHERE OU.OrganizationId = @OrganizationId diff --git a/util/Migrator/DbScripts/2021-07-07_00_FixBulkConfirm.sql b/util/Migrator/DbScripts/2021-07-07_00_FixBulkConfirm.sql new file mode 100644 index 0000000000..337b23287c --- /dev/null +++ b/util/Migrator/DbScripts/2021-07-07_00_FixBulkConfirm.sql @@ -0,0 +1,26 @@ +IF OBJECT_ID('[dbo].[User_ReadPublicKeysByOrganizationUserIds]') IS NOT NULL + BEGIN + DROP PROCEDURE [dbo].[User_ReadPublicKeysByOrganizationUserIds] + END +GO + +CREATE PROCEDURE [dbo].[User_ReadPublicKeysByOrganizationUserIds] + @OrganizationId UNIQUEIDENTIFIER, + @OrganizationUserIds [dbo].[GuidIdArray] READONLY +AS +BEGIN + SET NOCOUNT ON + + SELECT + OU.[Id], + OU.[UserId], + U.[PublicKey] + FROM + @OrganizationUserIds OUIDs + INNER JOIN + [dbo].[OrganizationUser] OU ON OUIDs.Id = OU.Id AND OU.[Status] = 1 -- Accepted + INNER JOIN + [dbo].[User] U ON OU.UserId = U.Id + WHERE + OU.OrganizationId = @OrganizationId +END