mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 13:08:17 -05:00
[PM-16888] Refactor OrganizationUser status update procedure to use a GuidIdArray parameter and remove JSON parsing logic (#5237)
* Refactor OrganizationUser status update procedure to use a GuidIdArray parameter and remove JSON parsing logic * Fix OrganizationUser_SetStatusForUsersById procedure and bump script date * Restore OrganizationUser_SetStatusForUsersById for possible server version rollback. Add new version with the name OrganizationUser_SetStatusForUsersByGuidIdArray * Add migration script to add stored procedure OrganizationUser_SetStatusForUsersByGuidIdArray to update user status by GUID array
This commit is contained in:
parent
7f0dd6d1c3
commit
bb3ec6aca1
@ -563,8 +563,8 @@ public class OrganizationUserRepository : Repository<OrganizationUser, Guid>, IO
|
|||||||
await using var connection = new SqlConnection(ConnectionString);
|
await using var connection = new SqlConnection(ConnectionString);
|
||||||
|
|
||||||
await connection.ExecuteAsync(
|
await connection.ExecuteAsync(
|
||||||
"[dbo].[OrganizationUser_SetStatusForUsersById]",
|
"[dbo].[OrganizationUser_SetStatusForUsersByGuidIdArray]",
|
||||||
new { OrganizationUserIds = JsonSerializer.Serialize(organizationUserIds), Status = OrganizationUserStatusType.Revoked },
|
new { OrganizationUserIds = organizationUserIds.ToGuidIdArrayTVP(), Status = OrganizationUserStatusType.Revoked },
|
||||||
commandType: CommandType.StoredProcedure);
|
commandType: CommandType.StoredProcedure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
CREATE PROCEDURE [dbo].[OrganizationUser_SetStatusForUsersByGuidIdArray]
|
||||||
|
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY,
|
||||||
|
@Status SMALLINT
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
UPDATE OU
|
||||||
|
SET OU.[Status] = @Status
|
||||||
|
FROM [dbo].[OrganizationUser] OU
|
||||||
|
INNER JOIN @OrganizationUserIds OUI ON OUI.[Id] = OU.[Id]
|
||||||
|
|
||||||
|
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
|
||||||
|
END
|
@ -0,0 +1,15 @@
|
|||||||
|
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUser_SetStatusForUsersByGuidIdArray]
|
||||||
|
@OrganizationUserIds AS [dbo].[GuidIdArray] READONLY,
|
||||||
|
@Status SMALLINT
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
UPDATE OU
|
||||||
|
SET OU.[Status] = @Status
|
||||||
|
FROM [dbo].[OrganizationUser] OU
|
||||||
|
INNER JOIN @OrganizationUserIds OUI ON OUI.[Id] = OU.[Id]
|
||||||
|
|
||||||
|
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
|
||||||
|
END
|
||||||
|
GO
|
Loading…
x
Reference in New Issue
Block a user