1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

Updated OrgIds to be a json string

This commit is contained in:
jrmccannon 2024-11-15 09:49:02 -06:00
parent 9427b9ff4c
commit 99f98f25ee
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6
2 changed files with 41 additions and 14 deletions

View File

@ -1,15 +1,29 @@
CREATE PROCEDURE [dbo].[OrganizationUser_SetStatusForUsersById]
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY,
@OrganizationUserIds AS NVARCHAR(MAX),
@Status SMALLINT
AS
BEGIN
SET NOCOUNT ON
-- Declare a table variable to hold the parsed JSON data
DECLARE @ParsedIds TABLE (Id UNIQUEIDENTIFIER);
-- Parse the JSON input into the table variable
INSERT INTO @ParsedIds (Id)
SELECT value
FROM OPENJSON(@OrganizationUserIds);
-- Check if the input table is empty
IF (SELECT COUNT(1) FROM @ParsedIds) < 1
BEGIN
RETURN(-1);
END
UPDATE
[dbo].[OrganizationUser]
SET
[Status] = @Status
WHERE
[Id] IN (SELECT Id from @OrganizationUserIds)
SET [Status] = @Status
WHERE [Id] IN (SELECT Id from @ParsedIds)
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
END
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds

View File

@ -1,15 +1,28 @@
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUser_SetStatusForUsersById]
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY,
CREATE PROCEDURE [dbo].[OrganizationUser_SetStatusForUsersById]
@OrganizationUserIds AS NVARCHAR(MAX),
@Status SMALLINT
AS
BEGIN
SET NOCOUNT ON
-- Declare a table variable to hold the parsed JSON data
DECLARE @ParsedIds TABLE (Id UNIQUEIDENTIFIER);
-- Parse the JSON input into the table variable
INSERT INTO @ParsedIds (Id)
SELECT value
FROM OPENJSON(@OrganizationUserIds);
-- Check if the input table is empty
IF (SELECT COUNT(1) FROM @ParsedIds) < 1
BEGIN
RETURN(-1);
END
UPDATE
[dbo].[OrganizationUser]
SET
[Status] = @Status
WHERE
[Id] IN (SELECT Id from @OrganizationUserIds)
END
SET [Status] = @Status
WHERE [Id] IN (SELECT Id from @ParsedIds)
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
END