From 2aa7c6cfe3334e8f96ce452f52d04d4058580e29 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 18 Apr 2017 15:27:54 -0400 Subject: [PATCH] org user remove fixes --- src/Core/Services/Implementations/OrganizationService.cs | 5 +++++ .../dbo/Stored Procedures/OrganizationUser_DeleteById.sql | 6 ++++++ 2 files changed, 11 insertions(+) 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]