mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 02:52:50 -05:00
[PM-15957] Fix: Domain Claim fails to enable Single Organization Policy, sends no emails and Revokes all users (#5147)
* Add JSON-based stored procedure for updating account revision dates and modify existing procedure to use it * Refactor SingleOrgPolicyValidator to revoke only non-compliant organization users and update related tests
This commit is contained in:
@ -24,6 +24,6 @@ BEGIN
|
||||
SET [Status] = @Status
|
||||
WHERE [Id] IN (SELECT Id from @ParsedIds)
|
||||
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIds] @OrganizationUserIds
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserIdsJson] @OrganizationUserIds
|
||||
END
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
CREATE PROCEDURE [dbo].[User_BumpAccountRevisionDateByOrganizationUserIdsJson]
|
||||
@OrganizationUserIds NVARCHAR(MAX)
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
CREATE TABLE #UserIds
|
||||
(
|
||||
UserId UNIQUEIDENTIFIER NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO #UserIds (UserId)
|
||||
SELECT
|
||||
OU.UserId
|
||||
FROM
|
||||
[dbo].[OrganizationUser] OU
|
||||
INNER JOIN
|
||||
(SELECT [value] as Id FROM OPENJSON(@OrganizationUserIds)) AS OUIds
|
||||
ON OUIds.Id = OU.Id
|
||||
WHERE
|
||||
OU.[Status] = 2 -- Confirmed
|
||||
|
||||
UPDATE
|
||||
U
|
||||
SET
|
||||
U.[AccountRevisionDate] = GETUTCDATE()
|
||||
FROM
|
||||
[dbo].[User] U
|
||||
INNER JOIN
|
||||
#UserIds ON U.[Id] = #UserIds.[UserId]
|
||||
|
||||
DROP TABLE #UserIds
|
||||
END
|
Reference in New Issue
Block a user