mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
Fix
This commit is contained in:
parent
e871c5f284
commit
7dc021090f
@ -1,11 +1,11 @@
|
|||||||
CREATE PROCEDURE [dbo].[OpaqueKeyExchangeCredential_Create]
|
CREATE PROCEDURE [dbo].[OpaqueKeyExchangeCredential_Create]
|
||||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
@UserId UNIQUEIDENTIFIER,
|
@UserId UNIQUEIDENTIFIER,
|
||||||
@CipherConfiguration VARCHAR(MAX) NOT NULL,
|
@CipherConfiguration VARCHAR(MAX),
|
||||||
@CredentialBlob VARCHAR(MAX) NOT NULL,
|
@CredentialBlob VARCHAR(MAX),
|
||||||
@EncryptedPublicKey VARCHAR(MAX) NOT NULL,
|
@EncryptedPublicKey VARCHAR(MAX),
|
||||||
@EncryptedPrivateKey VARCHAR(MAX) NOT NULL,
|
@EncryptedPrivateKey VARCHAR(MAX),
|
||||||
@EncryptedUserKey VARCHAR(MAX) NOT NULL,
|
@EncryptedUserKey VARCHAR(MAX),
|
||||||
@CreationDate DATETIME2(7)
|
@CreationDate DATETIME2(7)
|
||||||
AS
|
AS
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -22,11 +22,11 @@ GO
|
|||||||
CREATE OR ALTER PROCEDURE [dbo].[OpaqueKeyExchangeCredential_Create]
|
CREATE OR ALTER PROCEDURE [dbo].[OpaqueKeyExchangeCredential_Create]
|
||||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
@UserId UNIQUEIDENTIFIER,
|
@UserId UNIQUEIDENTIFIER,
|
||||||
@CipherConfiguration VARCHAR(MAX) NOT NULL,
|
@CipherConfiguration VARCHAR(MAX),
|
||||||
@CredentialBlob VARCHAR(MAX) NOT NULL,
|
@CredentialBlob VARCHAR(MAX),
|
||||||
@EncryptedPublicKey VARCHAR(MAX) NOT NULL,
|
@EncryptedPublicKey VARCHAR(MAX),
|
||||||
@EncryptedPrivateKey VARCHAR(MAX) NOT NULL,
|
@EncryptedPrivateKey VARCHAR(MAX),
|
||||||
@EncryptedUserKey VARCHAR(MAX) NOT NULL,
|
@EncryptedUserKey VARCHAR(MAX),
|
||||||
@CreationDate DATETIME2(7)
|
@CreationDate DATETIME2(7)
|
||||||
AS
|
AS
|
||||||
BEGIN
|
BEGIN
|
||||||
@ -128,156 +128,3 @@ BEGIN
|
|||||||
END
|
END
|
||||||
|
|
||||||
GO
|
GO
|
||||||
|
|
||||||
CREATE OR ALTER PROCEDURE [dbo].[User_DeleteById]
|
|
||||||
@Id UNIQUEIDENTIFIER
|
|
||||||
WITH
|
|
||||||
RECOMPILE
|
|
||||||
AS
|
|
||||||
BEGIN
|
|
||||||
SET NOCOUNT ON
|
|
||||||
DECLARE @BatchSize INT = 100
|
|
||||||
|
|
||||||
-- Delete ciphers
|
|
||||||
WHILE @BatchSize > 0
|
|
||||||
BEGIN
|
|
||||||
BEGIN TRANSACTION User_DeleteById_Ciphers
|
|
||||||
|
|
||||||
DELETE TOP(@BatchSize)
|
|
||||||
FROM
|
|
||||||
[dbo].[Cipher]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
SET @BatchSize = @@ROWCOUNT
|
|
||||||
|
|
||||||
COMMIT TRANSACTION User_DeleteById_Ciphers
|
|
||||||
END
|
|
||||||
|
|
||||||
BEGIN TRANSACTION User_DeleteById
|
|
||||||
-- Delete OpaqueKeyExchangeCredentials
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[OpaqueKeyExchangeCredential]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete WebAuthnCredentials
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[WebAuthnCredential]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete folders
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[Folder]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete AuthRequest, must be before Device
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[AuthRequest]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete devices
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[Device]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete collection users
|
|
||||||
DELETE
|
|
||||||
CU
|
|
||||||
FROM
|
|
||||||
[dbo].[CollectionUser] CU
|
|
||||||
INNER JOIN
|
|
||||||
[dbo].[OrganizationUser] OU ON OU.[Id] = CU.[OrganizationUserId]
|
|
||||||
WHERE
|
|
||||||
OU.[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete group users
|
|
||||||
DELETE
|
|
||||||
GU
|
|
||||||
FROM
|
|
||||||
[dbo].[GroupUser] GU
|
|
||||||
INNER JOIN
|
|
||||||
[dbo].[OrganizationUser] OU ON OU.[Id] = GU.[OrganizationUserId]
|
|
||||||
WHERE
|
|
||||||
OU.[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete AccessPolicy
|
|
||||||
DELETE
|
|
||||||
AP
|
|
||||||
FROM
|
|
||||||
[dbo].[AccessPolicy] AP
|
|
||||||
INNER JOIN
|
|
||||||
[dbo].[OrganizationUser] OU ON OU.[Id] = AP.[OrganizationUserId]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete organization users
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[OrganizationUser]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete provider users
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[ProviderUser]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete SSO Users
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[SsoUser]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete Emergency Accesses
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[EmergencyAccess]
|
|
||||||
WHERE
|
|
||||||
[GrantorId] = @Id
|
|
||||||
OR
|
|
||||||
[GranteeId] = @Id
|
|
||||||
|
|
||||||
-- Delete Sends
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[Send]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete Notification Status
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[NotificationStatus]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Delete Notification
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[Notification]
|
|
||||||
WHERE
|
|
||||||
[UserId] = @Id
|
|
||||||
|
|
||||||
-- Finally, delete the user
|
|
||||||
DELETE
|
|
||||||
FROM
|
|
||||||
[dbo].[User]
|
|
||||||
WHERE
|
|
||||||
[Id] = @Id
|
|
||||||
|
|
||||||
COMMIT TRANSACTION User_DeleteById
|
|
||||||
END
|
|
||||||
GO
|
|
Loading…
x
Reference in New Issue
Block a user