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

org.UseGroups check on all group saves

This commit is contained in:
Kyle Spearrin
2017-05-09 14:17:22 -04:00
parent a67b2b75a1
commit 71e9e82ea1
4 changed files with 78 additions and 21 deletions

View File

@ -16,16 +16,16 @@ namespace Bit.Api.Controllers
public class GroupsController : Controller
{
private readonly IGroupRepository _groupRepository;
private readonly IUserService _userService;
private readonly IGroupService _groupService;
private readonly CurrentContext _currentContext;
public GroupsController(
IGroupRepository groupRepository,
IUserService userService,
IGroupService groupService,
CurrentContext currentContext)
{
_groupRepository = groupRepository;
_userService = userService;
_groupService = groupService;
_currentContext = currentContext;
}
@ -77,15 +77,7 @@ namespace Bit.Api.Controllers
}
var group = model.ToGroup(orgIdGuid);
if(model.CollectionIds == null)
{
await _groupRepository.CreateAsync(group);
}
else
{
await _groupRepository.CreateAsync(group, model.CollectionIds.Select(c => new Guid(c)));
}
await _groupService.SaveAsync(group, model.CollectionIds?.Select(c => new Guid(c)));
return new GroupResponseModel(group);
}
@ -99,15 +91,7 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
if(model.CollectionIds == null)
{
await _groupRepository.ReplaceAsync(model.ToGroup(group));
}
else
{
await _groupRepository.ReplaceAsync(model.ToGroup(group), model.CollectionIds.Select(c => new Guid(c)));
}
await _groupService.SaveAsync(model.ToGroup(group), model.CollectionIds?.Select(c => new Guid(c)));
return new GroupResponseModel(group);
}