mirror of
https://github.com/bitwarden/server.git
synced 2025-04-08 14:38:15 -05:00
only get collection info when in an org
This commit is contained in:
parent
a956b826cd
commit
0502ba2451
@ -90,7 +90,7 @@ namespace Bit.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("")]
|
[HttpGet("")]
|
||||||
public async Task<ListResponseModel<CipherResponseModel>> Get([FromQuery]Core.Enums.CipherType? type = null)
|
public async Task<ListResponseModel<CipherDetailsResponseModel>> Get([FromQuery]Core.Enums.CipherType? type = null)
|
||||||
{
|
{
|
||||||
var userId = _userService.GetProperUserId(User).Value;
|
var userId = _userService.GetProperUserId(User).Value;
|
||||||
|
|
||||||
@ -104,8 +104,16 @@ namespace Bit.Api.Controllers
|
|||||||
ciphers = await _cipherRepository.GetManyByUserIdAsync(userId);
|
ciphers = await _cipherRepository.GetManyByUserIdAsync(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
var responses = ciphers.Select(c => new CipherResponseModel(c, _globalSettings)).ToList();
|
Dictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict = null;
|
||||||
return new ListResponseModel<CipherResponseModel>(responses);
|
if(_currentContext.Organizations.Any())
|
||||||
|
{
|
||||||
|
var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(userId);
|
||||||
|
collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
var responses = ciphers.Select(c => new CipherDetailsResponseModel(c, _globalSettings,
|
||||||
|
collectionCiphersGroupDict)).ToList();
|
||||||
|
return new ListResponseModel<CipherDetailsResponseModel>(responses);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("")]
|
[HttpPost("")]
|
||||||
@ -179,14 +187,19 @@ namespace Bit.Api.Controllers
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
[HttpGet("details")]
|
[HttpGet("details")]
|
||||||
public async Task<ListResponseModel<CipherDetailsResponseModel>> GetCollections()
|
public async Task<ListResponseModel<CipherDetailsResponseModel>> GetCollections()
|
||||||
{
|
{
|
||||||
var userId = _userService.GetProperUserId(User).Value;
|
var userId = _userService.GetProperUserId(User).Value;
|
||||||
var ciphers = await _cipherRepository.GetManyByUserIdHasCollectionsAsync(userId);
|
var ciphers = await _cipherRepository.GetManyByUserIdHasCollectionsAsync(userId);
|
||||||
|
|
||||||
var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(userId);
|
Dictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict = null;
|
||||||
var collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
|
if(_currentContext.Organizations.Any())
|
||||||
|
{
|
||||||
|
var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(userId);
|
||||||
|
collectionCiphersGroupDict = collectionCiphers.GroupBy(c => c.CipherId).ToDictionary(s => s.Key);
|
||||||
|
}
|
||||||
|
|
||||||
var responses = ciphers.Select(c => new CipherDetailsResponseModel(c, _globalSettings, collectionCiphersGroupDict));
|
var responses = ciphers.Select(c => new CipherDetailsResponseModel(c, _globalSettings, collectionCiphersGroupDict));
|
||||||
return new ListResponseModel<CipherDetailsResponseModel>(responses);
|
return new ListResponseModel<CipherDetailsResponseModel>(responses);
|
||||||
|
@ -58,9 +58,8 @@ namespace Bit.Api.Controllers
|
|||||||
var folders = await _folderRepository.GetManyByUserIdAsync(user.Id);
|
var folders = await _folderRepository.GetManyByUserIdAsync(user.Id);
|
||||||
var ciphers = await _cipherRepository.GetManyByUserIdAsync(user.Id);
|
var ciphers = await _cipherRepository.GetManyByUserIdAsync(user.Id);
|
||||||
|
|
||||||
IEnumerable<Collection> collections = new List<Collection>();
|
IEnumerable<Collection> collections = null;
|
||||||
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict =
|
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict = null;
|
||||||
new Dictionary<Guid, IGrouping<Guid, CollectionCipher>>();
|
|
||||||
if(organizationUserDetails.Any(o => o.Enabled))
|
if(organizationUserDetails.Any(o => o.Enabled))
|
||||||
{
|
{
|
||||||
collections = await _collectionRepository.GetManyByUserIdAsync(user.Id, false);
|
collections = await _collectionRepository.GetManyByUserIdAsync(user.Id, false);
|
||||||
|
@ -22,7 +22,7 @@ namespace Bit.Core.Models.Api
|
|||||||
Profile = new ProfileResponseModel(user, organizationUserDetails);
|
Profile = new ProfileResponseModel(user, organizationUserDetails);
|
||||||
Folders = folders.Select(f => new FolderResponseModel(f));
|
Folders = folders.Select(f => new FolderResponseModel(f));
|
||||||
Ciphers = ciphers.Select(c => new CipherDetailsResponseModel(c, globalSettings, collectionCiphersDict));
|
Ciphers = ciphers.Select(c => new CipherDetailsResponseModel(c, globalSettings, collectionCiphersDict));
|
||||||
Collections = collections.Select(c => new CollectionResponseModel(c));
|
Collections = collections?.Select(c => new CollectionResponseModel(c)) ?? new List<CollectionResponseModel>();
|
||||||
Domains = new DomainsResponseModel(user, false);
|
Domains = new DomainsResponseModel(user, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user