1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-26 12:55:17 +01:00
bitwarden-server/util/Migrator/DbScripts/2024-05-10_00_OrgUserReadManyAccountRecoveryDetailsByOrgUserIds.sql
Rui Tomé 5fabad35c7
[AC-2328] Add a Bulk OrganizationUsersController.GetResetPasswordDetails endpoint (#4079)
* Add new stored procedure for reading reset password details for multiple organization user IDs

* Add method IOrganizationUserRepository.GetManyResetPasswordDetailsByOrganizationUserAsync

* Add new API endpoint for getting reset password details for multiple organization users

* Add unit tests for bulk OrganizationUsersController.GetResetPasswordDetails

* Add alias to sql query result column

* Add constructor for automatic mapping

* Fix http method type for endpoint

* dotnet format

* Simplify the constructor in the OrganizationUserResetPasswordDetails

* Refactor stored procedure and repository method names for retrieving account recovery details

* Add integration tests for GetManyAccountRecoveryDetailsByOrganizationUserAsync

* Lock endpoint behind BulkDeviceApproval feature flag

* Update feature flag key value
2024-05-24 11:20:54 +01:00

25 lines
761 B
Transact-SQL

CREATE OR ALTER PROCEDURE [dbo].[OrganizationUser_ReadManyAccountRecoveryDetailsByOrganizationUserIds]
@OrganizationId UNIQUEIDENTIFIER,
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY
AS
BEGIN
SET NOCOUNT ON
SELECT
OU.[Id] AS OrganizationUserId,
U.[Kdf],
U.[KdfIterations],
U.[KdfMemory],
U.[KdfParallelism],
OU.[ResetPasswordKey],
O.[PrivateKey] AS EncryptedPrivateKey
FROM @OrganizationUserIds AS OUIDs
INNER JOIN [dbo].[OrganizationUser] AS OU
ON OUIDs.[Id] = OU.[Id]
INNER JOIN [dbo].[Organization] AS O
ON OU.[OrganizationId] = O.[Id]
INNER JOIN [dbo].[User] U
ON U.[Id] = OU.[UserId]
WHERE OU.[OrganizationId] = @OrganizationId
END