1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

[Key Connector] Prevent user from leaving org (#1715)

* Block user from leaving org using Key Connector

* Add tests
This commit is contained in:
Thomas Rittson
2021-11-15 19:46:13 +10:00
committed by GitHub
parent c2975b003d
commit e3143271d7
2 changed files with 87 additions and 0 deletions

View File

@ -384,6 +384,12 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
var ssoConfig = await _ssoConfigRepository.GetByOrganizationIdAsync(orgGuidId);
if (ssoConfig?.GetData()?.UseKeyConnector == true)
{
throw new BadRequestException("You cannot leave an Organization that is using Key Connector.");
}
var userId = _userService.GetProperUserId(User);
await _organizationService.DeleteUserAsync(orgGuidId, userId.Value);
}