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:
@ -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)
|
||||
|
Reference in New Issue
Block a user