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

PM-2427-Defect-Cannot-delete-account-if-User-has-auth-request-on-table-FK-constraint (#3118)

* updated migrations and ef repo

* removed route alias

---------

Co-authored-by: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com>
This commit is contained in:
Ike
2023-08-15 14:16:02 -07:00
committed by GitHub
parent c7b3759d55
commit 4ec01b0ef0
4 changed files with 149 additions and 7 deletions

View File

@ -14,8 +14,6 @@ using Microsoft.AspNetCore.Mvc;
namespace Bit.Identity.Controllers;
// TODO: 2022-01-12, Remove account alias
[Route("account/[action]")]
[Route("sso/[action]")]
public class SsoController : Controller
{

View File

@ -155,6 +155,7 @@ public class UserRepository : Repository<Core.Entities.User, User, Guid>, IUserR
dbContext.Ciphers.RemoveRange(dbContext.Ciphers.Where(c => c.UserId == user.Id));
dbContext.Folders.RemoveRange(dbContext.Folders.Where(f => f.UserId == user.Id));
dbContext.AuthRequests.RemoveRange(dbContext.AuthRequests.Where(s => s.UserId == user.Id));
dbContext.Devices.RemoveRange(dbContext.Devices.Where(d => d.UserId == user.Id));
var collectionUsers = from cu in dbContext.CollectionUsers
join ou in dbContext.OrganizationUsers on cu.OrganizationUserId equals ou.Id

View File

@ -31,6 +31,13 @@ BEGIN
WHERE
[UserId] = @Id
-- Delete AuthRequest, must be before Device
DELETE
FROM
[dbo].[AuthRequest]
WHERE
[UserId] = @Id
-- Delete devices
DELETE
FROM
@ -43,7 +50,7 @@ BEGIN
CU
FROM
[dbo].[CollectionUser] CU
INNER JOIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = CU.[OrganizationUserId]
WHERE
OU.[UserId] = @Id
@ -53,7 +60,7 @@ BEGIN
GU
FROM
[dbo].[GroupUser] GU
INNER JOIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = GU.[OrganizationUserId]
WHERE
OU.[UserId] = @Id
@ -63,7 +70,7 @@ BEGIN
AP
FROM
[dbo].[AccessPolicy] AP
INNER JOIN
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = AP.[OrganizationUserId]
WHERE
[UserId] = @Id
@ -95,7 +102,7 @@ BEGIN
[dbo].[EmergencyAccess]
WHERE
[GrantorId] = @Id
OR
OR
[GranteeId] = @Id
-- Delete Sends
@ -104,7 +111,7 @@ BEGIN
[dbo].[Send]
WHERE
[UserId] = @Id
-- Finally, delete the user
DELETE
FROM