mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 13:38:13 -05:00
[PM-6325] Include permission details for non FC organizations when creating/updating a collection (#3810)
This commit is contained in:
parent
7f752fbd62
commit
da0da772e9
@ -253,7 +253,18 @@ public class CollectionsController : Controller
|
||||
|
||||
await _collectionService.SaveAsync(collection, groups, users);
|
||||
|
||||
return new CollectionResponseModel(collection);
|
||||
if (!_currentContext.UserId.HasValue || await _currentContext.ProviderUserForOrgAsync(orgId))
|
||||
{
|
||||
return new CollectionResponseModel(collection);
|
||||
}
|
||||
|
||||
// If we have a user, fetch the collection to get the latest permission details
|
||||
var userCollectionDetails = await _collectionRepository.GetByIdAsync(collection.Id,
|
||||
_currentContext.UserId.Value, await FlexibleCollectionsIsEnabledAsync(collection.OrganizationId));
|
||||
|
||||
return userCollectionDetails == null
|
||||
? new CollectionResponseModel(collection)
|
||||
: new CollectionDetailsResponseModel(userCollectionDetails);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
@ -276,7 +287,18 @@ public class CollectionsController : Controller
|
||||
var groups = model.Groups?.Select(g => g.ToSelectionReadOnly());
|
||||
var users = model.Users?.Select(g => g.ToSelectionReadOnly());
|
||||
await _collectionService.SaveAsync(model.ToCollection(collection), groups, users);
|
||||
return new CollectionResponseModel(collection);
|
||||
|
||||
if (!_currentContext.UserId.HasValue || await _currentContext.ProviderUserForOrgAsync(collection.OrganizationId))
|
||||
{
|
||||
return new CollectionResponseModel(collection);
|
||||
}
|
||||
|
||||
// If we have a user, fetch the collection details to get the latest permission details for the user
|
||||
var updatedCollectionDetails = await _collectionRepository.GetByIdAsync(id, _currentContext.UserId.Value, await FlexibleCollectionsIsEnabledAsync(collection.OrganizationId));
|
||||
|
||||
return updatedCollectionDetails == null
|
||||
? new CollectionResponseModel(collection)
|
||||
: new CollectionDetailsResponseModel(updatedCollectionDetails);
|
||||
}
|
||||
|
||||
[HttpPut("{id}/users")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user