mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
api adjustments for manager role and collections
This commit is contained in:
@ -33,7 +33,8 @@ namespace Bit.Core.Services
|
||||
_mailService = mailService;
|
||||
}
|
||||
|
||||
public async Task SaveAsync(Collection collection, IEnumerable<SelectionReadOnly> groups = null)
|
||||
public async Task SaveAsync(Collection collection, IEnumerable<SelectionReadOnly> groups = null,
|
||||
Guid? assignUserId = null)
|
||||
{
|
||||
var org = await _organizationRepository.GetByIdAsync(collection.OrganizationId);
|
||||
if(org == null)
|
||||
@ -62,6 +63,18 @@ namespace Bit.Core.Services
|
||||
await _collectionRepository.CreateAsync(collection, groups);
|
||||
}
|
||||
|
||||
// Assign a user to the newly created collection.
|
||||
if(assignUserId.HasValue)
|
||||
{
|
||||
var orgUser = await _organizationUserRepository.GetByOrganizationAsync(org.Id, assignUserId.Value);
|
||||
if(orgUser != null && orgUser.Status == Enums.OrganizationUserStatusType.Confirmed)
|
||||
{
|
||||
await _collectionRepository.UpdateUsersAsync(collection.Id,
|
||||
new List<SelectionReadOnly> {
|
||||
new SelectionReadOnly { Id = orgUser.Id, ReadOnly = false } });
|
||||
}
|
||||
}
|
||||
|
||||
await _eventService.LogCollectionEventAsync(collection, Enums.EventType.Collection_Created);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user