mirror of
https://github.com/bitwarden/server
synced 2026-01-19 17:03:16 +00:00
[Soft Delete] - API updates for soft delete + retrieval
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
CREATE PROCEDURE [dbo].[Cipher_Delete]
|
||||
@Ids AS [dbo].[GuidIdArray] READONLY,
|
||||
@UserId AS UNIQUEIDENTIFIER,
|
||||
@Permanent AS BIT
|
||||
@UserId AS UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
@@ -27,23 +26,11 @@ BEGIN
|
||||
AND [Id] IN (SELECT * FROM @Ids)
|
||||
|
||||
-- Delete ciphers
|
||||
IF @Permanent = 1
|
||||
BEGIN
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[Cipher]
|
||||
WHERE
|
||||
[Id] IN (SELECT [Id] FROM #Temp)
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
UPDATE
|
||||
[dbo].[Cipher]
|
||||
SET
|
||||
[DeletedDate] = SYSUTCDATETIME()
|
||||
WHERE
|
||||
[Id] IN (SELECT [Id] FROM #Temp)
|
||||
END
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[Cipher]
|
||||
WHERE
|
||||
[Id] IN (SELECT [Id] FROM #Temp)
|
||||
|
||||
-- Cleanup orgs
|
||||
DECLARE @OrgId UNIQUEIDENTIFIER
|
||||
@@ -59,11 +46,7 @@ BEGIN
|
||||
OPEN [OrgCursor]
|
||||
FETCH NEXT FROM [OrgCursor] INTO @OrgId
|
||||
WHILE @@FETCH_STATUS = 0 BEGIN
|
||||
-- Storage cleanup for groups only matters if we're permanently deleting
|
||||
IF @Permanent = 1
|
||||
BEGIN
|
||||
EXEC [dbo].[Organization_UpdateStorage] @OrgId
|
||||
END
|
||||
EXEC [dbo].[Organization_UpdateStorage] @OrgId
|
||||
EXEC [dbo].[User_BumpAccountRevisionDateByOrganizationId] @OrgId
|
||||
FETCH NEXT FROM [OrgCursor] INTO @OrgId
|
||||
END
|
||||
@@ -71,22 +54,18 @@ BEGIN
|
||||
DEALLOCATE [OrgCursor]
|
||||
|
||||
-- Cleanup user
|
||||
IF @Permanent = 1
|
||||
BEGIN
|
||||
-- Storage cleanup for users only matters if we're permanently deleting
|
||||
DECLARE @UserCiphersWithStorageCount INT
|
||||
SELECT
|
||||
@UserCiphersWithStorageCount = COUNT(1)
|
||||
FROM
|
||||
#Temp
|
||||
WHERE
|
||||
[UserId] IS NOT NULL
|
||||
AND [Attachments] = 1
|
||||
DECLARE @UserCiphersWithStorageCount INT
|
||||
SELECT
|
||||
@UserCiphersWithStorageCount = COUNT(1)
|
||||
FROM
|
||||
#Temp
|
||||
WHERE
|
||||
[UserId] IS NOT NULL
|
||||
AND [Attachments] = 1
|
||||
|
||||
IF @UserCiphersWithStorageCount > 0
|
||||
BEGIN
|
||||
EXEC [dbo].[User_UpdateStorage] @UserId
|
||||
END
|
||||
IF @UserCiphersWithStorageCount > 0
|
||||
BEGIN
|
||||
EXEC [dbo].[User_UpdateStorage] @UserId
|
||||
END
|
||||
EXEC [dbo].[User_BumpAccountRevisionDate] @UserId
|
||||
|
||||
|
||||
Reference in New Issue
Block a user