1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

create/get/update collection with groups

This commit is contained in:
Kyle Spearrin
2017-05-09 12:41:36 -04:00
parent d166f9cca3
commit 6c923102e9
11 changed files with 196 additions and 6 deletions

View File

@ -47,6 +47,18 @@ namespace Bit.Api.Controllers
return new CollectionResponseModel(collection);
}
[HttpGet("{id}/details")]
public async Task<CollectionDetailsResponseModel> GetDetails(string orgId, string id)
{
var collectionDetails = await _collectionRepository.GetByIdWithGroupsAsync(new Guid(id));
if(collectionDetails?.Item1 == null || !_currentContext.OrganizationAdmin(collectionDetails.Item1.OrganizationId))
{
throw new NotFoundException();
}
return new CollectionDetailsResponseModel(collectionDetails.Item1, collectionDetails.Item2);
}
[HttpGet("")]
public async Task<ListResponseModel<CollectionResponseModel>> Get(string orgId)
{
@ -80,7 +92,7 @@ namespace Bit.Api.Controllers
}
var collection = model.ToCollection(orgIdGuid);
await _collectionService.SaveAsync(collection);
await _collectionService.SaveAsync(collection, model?.GroupIds.Select(g => new Guid(g)));
return new CollectionResponseModel(collection);
}
@ -94,7 +106,7 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
await _collectionService.SaveAsync(model.ToCollection(collection));
await _collectionService.SaveAsync(model.ToCollection(collection), model?.GroupIds.Select(g => new Guid(g)));
return new CollectionResponseModel(collection);
}