diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 9d44359113..156011133a 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -797,6 +797,11 @@ namespace Bit.Core.Services throw new BadRequestException("User not valid."); } + if(orgUser.UserId == deletingUserId) + { + throw new BadRequestException("You cannot remove yourself."); + } + var confirmedOwners = (await GetConfirmedOwnersAsync(organizationId)).ToList(); if(confirmedOwners.Count == 1 && confirmedOwners[0].Id == organizationUserId) { diff --git a/src/Sql/dbo/Stored Procedures/OrganizationUser_DeleteById.sql b/src/Sql/dbo/Stored Procedures/OrganizationUser_DeleteById.sql index 45a2b01bda..60bc4e1a4d 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationUser_DeleteById.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationUser_DeleteById.sql @@ -4,6 +4,12 @@ AS BEGIN SET NOCOUNT ON + DELETE + FROM + [dbo].[SubvaultUser] + WHERE + [OrganizationUserId] = @Id + DELETE FROM [dbo].[OrganizationUser]