1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-27 13:05:23 +01:00

change routing for org import

This commit is contained in:
Kyle Spearrin 2017-09-06 09:06:13 -04:00
parent 95181aef89
commit 06bdda5717

View File

@ -120,18 +120,18 @@ namespace Bit.Api.Controllers
await _cipherService.ImportCiphersAsync(folders, ciphers, model.FolderRelationships); await _cipherService.ImportCiphersAsync(folders, ciphers, model.FolderRelationships);
} }
[HttpPost("{orgId}/import")] [HttpPost("import-organization")]
public async Task PostImport(string orgId, [FromBody]ImportOrganizationCiphersRequestModel model) public async Task PostImport([FromQuery]string organizationId, [FromBody]ImportOrganizationCiphersRequestModel model)
{ {
var organizationId = new Guid(orgId); var orgId = new Guid(organizationId);
if(!_currentContext.OrganizationAdmin(organizationId)) if(!_currentContext.OrganizationAdmin(orgId))
{ {
throw new NotFoundException(); throw new NotFoundException();
} }
var userId = _userService.GetProperUserId(User).Value; var userId = _userService.GetProperUserId(User).Value;
var collections = model.Collections.Select(c => c.ToCollection(organizationId)).ToList(); var collections = model.Collections.Select(c => c.ToCollection(orgId)).ToList();
var ciphers = model.Logins.Select(l => l.ToOrganizationCipherDetails(organizationId)).ToList(); var ciphers = model.Logins.Select(l => l.ToOrganizationCipherDetails(orgId)).ToList();
await _cipherService.ImportCiphersAsync(collections, ciphers, model.CollectionRelationships, userId); await _cipherService.ImportCiphersAsync(collections, ciphers, model.CollectionRelationships, userId);
} }