1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-26 12:55:17 +01:00

pass orgid from app code rather than querying it

This commit is contained in:
Kyle Spearrin 2017-05-04 07:23:40 -04:00
parent 5b5bd4e099
commit 4ab53d476c
4 changed files with 8 additions and 7 deletions

View File

@ -42,7 +42,8 @@ namespace Bit.Api.Controllers
throw new NotFoundException();
}
var collectionUsers = await _collectionUserRepository.GetManyDetailsByCollectionIdAsync(collectionIdGuid);
var collectionUsers = await _collectionUserRepository.GetManyDetailsByCollectionIdAsync(collection.OrganizationId,
collection.Id);
var responses = collectionUsers.Select(c => new CollectionUserResponseModel(c));
return new ListResponseModel<CollectionUserResponseModel>(responses);
}

View File

@ -10,7 +10,7 @@ namespace Bit.Core.Repositories
{
Task<ICollection<CollectionUser>> GetManyByOrganizationUserIdAsync(Guid orgUserId);
Task<ICollection<CollectionUserCollectionDetails>> GetManyDetailsByUserIdAsync(Guid userId);
Task<ICollection<CollectionUserUserDetails>> GetManyDetailsByCollectionIdAsync(Guid collectionId);
Task<ICollection<CollectionUserUserDetails>> GetManyDetailsByCollectionIdAsync(Guid organizationId, Guid collectionId);
Task<bool> GetCanEditByUserIdCipherIdAsync(Guid userId, Guid cipherId);
}
}

View File

@ -46,13 +46,14 @@ namespace Bit.Core.Repositories.SqlServer
}
}
public async Task<ICollection<CollectionUserUserDetails>> GetManyDetailsByCollectionIdAsync(Guid collectionId)
public async Task<ICollection<CollectionUserUserDetails>> GetManyDetailsByCollectionIdAsync(Guid organizationId,
Guid collectionId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<CollectionUserUserDetails>(
$"[{Schema}].[CollectionUserUserDetails_ReadByCollectionId]",
new { CollectionId = collectionId },
new { OrganizationId = organizationId, CollectionId = collectionId },
commandType: CommandType.StoredProcedure);
return results.ToList();

View File

@ -1,11 +1,10 @@
CREATE PROCEDURE [dbo].[CollectionUserUserDetails_ReadByCollectionId]
@CollectionId UNIQUEIDENTIFIER
@CollectionId UNIQUEIDENTIFIER,
@OrganizationId UNIQUEIDENTIFIER
AS
BEGIN
SET NOCOUNT ON
DECLARE @OrganizationId UNIQUEIDENTIFIER = (SELECT [OrganizationId] FROM [dbo].[Collection] WHERE [Id] = @CollectionId)
SELECT
*
FROM