diff --git a/src/Core/Models/Data/CollectionUserUserDetails.cs b/src/Core/Models/Data/CollectionUserUserDetails.cs index 6611f8f1ae..09344ce826 100644 --- a/src/Core/Models/Data/CollectionUserUserDetails.cs +++ b/src/Core/Models/Data/CollectionUserUserDetails.cs @@ -6,6 +6,7 @@ namespace Bit.Core.Models.Data { public Guid? Id { get; set; } public Guid OrganizationUserId { get; set; } + public Guid? OrganizationId { get; set; } public Guid? CollectionId { get; set; } public bool AccessAll { get; set; } public string Name { get; set; } diff --git a/src/Sql/dbo/Stored Procedures/CollectionUserUserDetails_ReadByCollectionId.sql b/src/Sql/dbo/Stored Procedures/CollectionUserUserDetails_ReadByCollectionId.sql index d8c18d8207..7e6356381a 100644 --- a/src/Sql/dbo/Stored Procedures/CollectionUserUserDetails_ReadByCollectionId.sql +++ b/src/Sql/dbo/Stored Procedures/CollectionUserUserDetails_ReadByCollectionId.sql @@ -4,11 +4,17 @@ AS BEGIN SET NOCOUNT ON + DECLARE @OrganizationId UNIQUEIDENTIFIER = (SELECT [OrganizationId] FROM [dbo].[Collection] WHERE [Id] = @CollectionId) + SELECT * FROM [dbo].[CollectionUserUserDetailsView] WHERE - [AccessAll] = 1 - OR [CollectionId] = @CollectionId -END \ No newline at end of file + [CollectionId] = @CollectionId + OR + ( + [OrganizationId] = @OrganizationId + AND [AccessAll] = 1 + ) +END diff --git a/src/Sql/dbo/Views/CollectionUserUserDetailsView.sql b/src/Sql/dbo/Views/CollectionUserUserDetailsView.sql index 101927070f..8e05d79236 100644 --- a/src/Sql/dbo/Views/CollectionUserUserDetailsView.sql +++ b/src/Sql/dbo/Views/CollectionUserUserDetailsView.sql @@ -2,6 +2,7 @@ AS SELECT OU.[Id] AS [OrganizationUserId], + OU.[OrganizationId], OU.[AccessAll], CU.[Id], CU.[CollectionId],