1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 16:42:50 -05:00

purge org vault

This commit is contained in:
Kyle Spearrin
2018-09-25 09:12:50 -04:00
parent e34fe81857
commit 7164f378fc
10 changed files with 150 additions and 3 deletions

View File

@ -376,7 +376,7 @@ namespace Bit.Api.Controllers
}
[HttpPost("purge")]
public async Task PostPurge([FromBody]CipherPurgeRequestModel model)
public async Task PostPurge([FromBody]CipherPurgeRequestModel model, string organizationId = null)
{
var user = await _userService.GetUserByPrincipalAsync(User);
if(user == null)
@ -391,7 +391,19 @@ namespace Bit.Api.Controllers
throw new BadRequestException(ModelState);
}
await _cipherRepository.DeleteByUserIdAsync(user.Id);
if(string.IsNullOrWhiteSpace(organizationId))
{
await _cipherRepository.DeleteByUserIdAsync(user.Id);
}
else
{
var orgId = new Guid(organizationId);
if(!_currentContext.OrganizationAdmin(orgId))
{
throw new NotFoundException();
}
await _cipherService.PurgeAsync(orgId);
}
}
[HttpPost("{id}/attachment")]