mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
delete sso config when deleting org (#904)
* delete ssouser on org and user delete * delete sso config when deleting org
This commit is contained in:
parent
47224913d4
commit
8510a753a8
@ -23,15 +23,25 @@ BEGIN
|
|||||||
COMMIT TRANSACTION Organization_DeleteById_Ciphers
|
COMMIT TRANSACTION Organization_DeleteById_Ciphers
|
||||||
END
|
END
|
||||||
|
|
||||||
|
BEGIN TRANSACTION Organization_DeleteById
|
||||||
|
|
||||||
DELETE
|
DELETE
|
||||||
FROM
|
FROM
|
||||||
[dbo].[SsoUser]
|
[dbo].[SsoUser]
|
||||||
WHERE
|
WHERE
|
||||||
[OrganizationId] = @Id
|
[OrganizationId] = @Id
|
||||||
|
|
||||||
|
DELETE
|
||||||
|
FROM
|
||||||
|
[dbo].[SsoConfig]
|
||||||
|
WHERE
|
||||||
|
[OrganizationId] = @Id
|
||||||
|
|
||||||
DELETE
|
DELETE
|
||||||
FROM
|
FROM
|
||||||
[dbo].[Organization]
|
[dbo].[Organization]
|
||||||
WHERE
|
WHERE
|
||||||
[Id] = @Id
|
[Id] = @Id
|
||||||
|
|
||||||
|
COMMIT TRANSACTION Organization_DeleteById
|
||||||
END
|
END
|
54
util/Migrator/DbScripts/2020-09-02_00_DeleteSsoConfig.sql
Normal file
54
util/Migrator/DbScripts/2020-09-02_00_DeleteSsoConfig.sql
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
IF OBJECT_ID('[dbo].[Organization_DeleteById]') IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
DROP PROCEDURE [dbo].[Organization_DeleteById]
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE PROCEDURE [dbo].[Organization_DeleteById]
|
||||||
|
@Id UNIQUEIDENTIFIER
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationId] @Id
|
||||||
|
|
||||||
|
DECLARE @BatchSize INT = 100
|
||||||
|
WHILE @BatchSize > 0
|
||||||
|
BEGIN
|
||||||
|
BEGIN TRANSACTION Organization_DeleteById_Ciphers
|
||||||
|
|
||||||
|
DELETE TOP(@BatchSize)
|
||||||
|
FROM
|
||||||
|
[dbo].[Cipher]
|
||||||
|
WHERE
|
||||||
|
[UserId] IS NULL
|
||||||
|
AND [OrganizationId] = @Id
|
||||||
|
|
||||||
|
SET @BatchSize = @@ROWCOUNT
|
||||||
|
|
||||||
|
COMMIT TRANSACTION Organization_DeleteById_Ciphers
|
||||||
|
END
|
||||||
|
|
||||||
|
BEGIN TRANSACTION Organization_DeleteById
|
||||||
|
|
||||||
|
DELETE
|
||||||
|
FROM
|
||||||
|
[dbo].[SsoUser]
|
||||||
|
WHERE
|
||||||
|
[OrganizationId] = @Id
|
||||||
|
|
||||||
|
DELETE
|
||||||
|
FROM
|
||||||
|
[dbo].[SsoConfig]
|
||||||
|
WHERE
|
||||||
|
[OrganizationId] = @Id
|
||||||
|
|
||||||
|
DELETE
|
||||||
|
FROM
|
||||||
|
[dbo].[Organization]
|
||||||
|
WHERE
|
||||||
|
[Id] = @Id
|
||||||
|
|
||||||
|
COMMIT TRANSACTION Organization_DeleteById
|
||||||
|
END
|
||||||
|
GO
|
Loading…
x
Reference in New Issue
Block a user