1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 01:22:50 -05:00

organization cipher import with collections

This commit is contained in:
Kyle Spearrin
2017-09-05 17:49:34 -04:00
parent e7aa6980d5
commit 95181aef89
9 changed files with 228 additions and 25 deletions

View File

@ -112,7 +112,7 @@ namespace Bit.Api.Controllers
}
[HttpPost("import")]
public async Task PostImport([FromBody]ImportPasswordsRequestModel model)
public async Task PostImport([FromBody]ImportCiphersRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
var folders = model.Folders.Select(f => f.ToFolder(userId)).ToList();
@ -120,6 +120,21 @@ namespace Bit.Api.Controllers
await _cipherService.ImportCiphersAsync(folders, ciphers, model.FolderRelationships);
}
[HttpPost("{orgId}/import")]
public async Task PostImport(string orgId, [FromBody]ImportOrganizationCiphersRequestModel model)
{
var organizationId = new Guid(orgId);
if(!_currentContext.OrganizationAdmin(organizationId))
{
throw new NotFoundException();
}
var userId = _userService.GetProperUserId(User).Value;
var collections = model.Collections.Select(c => c.ToCollection(organizationId)).ToList();
var ciphers = model.Logins.Select(l => l.ToOrganizationCipherDetails(organizationId)).ToList();
await _cipherService.ImportCiphersAsync(collections, ciphers, model.CollectionRelationships, userId);
}
[HttpPut("{id}/partial")]
[HttpPost("{id}/partial")]
public async Task PutPartial(string id, [FromBody]CipherPartialRequestModel model)