mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Add API for bulk removal of org users (#1320)
* Add API for bulk removal of org users * Refactor OrganizationService, extract some common code. * Add tests for DeleteUserAsync * Add tests for DeleteUsers * Formating * Update test/Core.Test/Services/OrganizationServiceTests.cs added a space Co-authored-by: Addison Beck <abeck@bitwarden.com>
This commit is contained in:
@ -131,7 +131,7 @@ namespace Bit.Api.Controllers
|
||||
}
|
||||
|
||||
[HttpPost("reinvite")]
|
||||
public async Task BulkReinvite(string orgId, [FromBody]OrganizationUserBulkReinviteRequestModel model)
|
||||
public async Task BulkReinvite(string orgId, [FromBody]OrganizationUserBulkRequestModel model)
|
||||
{
|
||||
var orgGuidId = new Guid(orgId);
|
||||
if (!_currentContext.ManageUsers(orgGuidId))
|
||||
@ -283,5 +283,19 @@ namespace Bit.Api.Controllers
|
||||
var userId = _userService.GetProperUserId(User);
|
||||
await _organizationService.DeleteUserAsync(orgGuidId, new Guid(id), userId.Value);
|
||||
}
|
||||
|
||||
[HttpDelete("")]
|
||||
[HttpPost("delete")]
|
||||
public async Task BulkDelete(string orgId, [FromBody]OrganizationUserBulkRequestModel model)
|
||||
{
|
||||
var orgGuidId = new Guid(orgId);
|
||||
if (!_currentContext.ManageUsers(orgGuidId))
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
var userId = _userService.GetProperUserId(User);
|
||||
await _organizationService.DeleteUsersAsync(orgGuidId, model.Ids, userId.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user