1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

apis for purging user vault

This commit is contained in:
Kyle Spearrin
2017-10-25 21:26:09 -04:00
parent 3e04377e67
commit a042fd10f1
6 changed files with 84 additions and 0 deletions

View File

@ -294,3 +294,39 @@ BEGIN
[Id] = @Id
END
GO
IF OBJECT_ID('[dbo].[Cipher_DeleteByUserId]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[Cipher_DeleteByUserId]
END
GO
CREATE PROCEDURE [dbo].[Cipher_DeleteByUserId]
@UserId AS UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
DECLARE @BatchSize INT = 100
-- Delete ciphers
WHILE @BatchSize > 0
BEGIN
BEGIN TRANSACTION Cipher_DeleteByUserId_Ciphers
DELETE TOP(@BatchSize)
FROM
[dbo].[Cipher]
WHERE
[UserId] = @UserId
SET @BatchSize = @@ROWCOUNT
COMMIT TRANSACTION Cipher_DeleteByUserId_Ciphers
END
-- Cleanup user
EXEC [dbo].[User_UpdateStorage] @UserId
EXEC [dbo].[User_BumpAccountRevisionDate] @UserId
END
GO