diff --git a/src/Api/Controllers/CollectionUsersController.cs b/src/Api/Controllers/CollectionUsersController.cs index 58f52a751..1f568905f 100644 --- a/src/Api/Controllers/CollectionUsersController.cs +++ b/src/Api/Controllers/CollectionUsersController.cs @@ -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(responses); } diff --git a/src/Core/Repositories/ICollectionUserRepository.cs b/src/Core/Repositories/ICollectionUserRepository.cs index dc8186c86..fe80c85b2 100644 --- a/src/Core/Repositories/ICollectionUserRepository.cs +++ b/src/Core/Repositories/ICollectionUserRepository.cs @@ -10,7 +10,7 @@ namespace Bit.Core.Repositories { Task> GetManyByOrganizationUserIdAsync(Guid orgUserId); Task> GetManyDetailsByUserIdAsync(Guid userId); - Task> GetManyDetailsByCollectionIdAsync(Guid collectionId); + Task> GetManyDetailsByCollectionIdAsync(Guid organizationId, Guid collectionId); Task GetCanEditByUserIdCipherIdAsync(Guid userId, Guid cipherId); } } diff --git a/src/Core/Repositories/SqlServer/CollectionUserRepository.cs b/src/Core/Repositories/SqlServer/CollectionUserRepository.cs index cdd5deabe..5a51936c3 100644 --- a/src/Core/Repositories/SqlServer/CollectionUserRepository.cs +++ b/src/Core/Repositories/SqlServer/CollectionUserRepository.cs @@ -46,13 +46,14 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyDetailsByCollectionIdAsync(Guid collectionId) + public async Task> GetManyDetailsByCollectionIdAsync(Guid organizationId, + Guid collectionId) { using(var connection = new SqlConnection(ConnectionString)) { var results = await connection.QueryAsync( $"[{Schema}].[CollectionUserUserDetails_ReadByCollectionId]", - new { CollectionId = collectionId }, + new { OrganizationId = organizationId, CollectionId = collectionId }, commandType: CommandType.StoredProcedure); return results.ToList(); diff --git a/src/Sql/dbo/Stored Procedures/CollectionUserUserDetails_ReadByCollectionId.sql b/src/Sql/dbo/Stored Procedures/CollectionUserUserDetails_ReadByCollectionId.sql index 7e6356381..ecdcb4ae3 100644 --- a/src/Sql/dbo/Stored Procedures/CollectionUserUserDetails_ReadByCollectionId.sql +++ b/src/Sql/dbo/Stored Procedures/CollectionUserUserDetails_ReadByCollectionId.sql @@ -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