mirror of
https://github.com/bitwarden/server.git
synced 2025-04-04 20:50:21 -05:00
delete sso user when deleting org user (#901)
This commit is contained in:
parent
01bae115a5
commit
9faa9406a6
@ -5,6 +5,22 @@ BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserId] @Id
|
||||
|
||||
DECLARE @OrganizationId UNIQUEIDENTIFIER
|
||||
DECLARE @UserId UNIQUEIDENTIFIER
|
||||
|
||||
SELECT
|
||||
@OrganizationId = [OrganizationId],
|
||||
@UserId = [UserId]
|
||||
FROM
|
||||
[dbo].[OrganizationUser]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
|
||||
IF @OrganizationId IS NOT NULL AND @UserId IS NOT NULL
|
||||
BEGIN
|
||||
EXEC [dbo].[SsoUser_Delete] @UserId, @OrganizationId
|
||||
END
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
|
49
util/Migrator/DbScripts/2020-09-01_00_DeleteSsoUser.sql
Normal file
49
util/Migrator/DbScripts/2020-09-01_00_DeleteSsoUser.sql
Normal file
@ -0,0 +1,49 @@
|
||||
IF OBJECT_ID('[dbo].[OrganizationUser_DeleteById]') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE [dbo].[OrganizationUser_DeleteById]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[OrganizationUser_DeleteById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationUserId] @Id
|
||||
|
||||
DECLARE @OrganizationId UNIQUEIDENTIFIER
|
||||
DECLARE @UserId UNIQUEIDENTIFIER
|
||||
|
||||
SELECT
|
||||
@OrganizationId = [OrganizationId],
|
||||
@UserId = [UserId]
|
||||
FROM
|
||||
[dbo].[OrganizationUser]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
|
||||
IF @OrganizationId IS NOT NULL AND @UserId IS NOT NULL
|
||||
BEGIN
|
||||
EXEC [dbo].[SsoUser_Delete] @UserId, @OrganizationId
|
||||
END
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[CollectionUser]
|
||||
WHERE
|
||||
[OrganizationUserId] = @Id
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[GroupUser]
|
||||
WHERE
|
||||
[OrganizationUserId] = @Id
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[OrganizationUser]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
||||
GO
|
Loading…
x
Reference in New Issue
Block a user