mirror of
https://github.com/bitwarden/server
synced 2025-12-06 00:03:34 +00:00
* Refactor ICollectionRepository.GetManyByOrganizationIdAsync logic to include default user collections * Add stored procedure Collection_ReadSharedCollectionsByOrganizationId to retrieve collections by organization ID, excluding default user collections. * Add GetManySharedCollectionsByOrganizationIdAsync method to ICollectionRepository and its implementations to retrieve collections excluding default user collections. * Add unit test for GetManySharedCollectionsByOrganizationIdAsync method in CollectionRepositoryTests to verify retrieval of collections excluding default user collections. * Refactor controllers to use GetManySharedCollectionsByOrganizationIdAsync for retrieving shared collections * Update unit tests to use GetManySharedCollectionsByOrganizationIdAsync for verifying shared collections retrieval * Revert CiphersController.CanEditItemsInCollections to use GetManyByOrganizationIdAsync for retrieving organization collections * Update stored procedures to retrieve only DefaultUserCollection by modifying the WHERE clause in Collection_ReadSharedCollectionsByOrganizationId.sql and its corresponding migration script. * Update EF CollectionRepository.GetManySharedCollectionsByOrganizationIdAsync to filter collections by SharedCollection * Update OrganizationUserRepository.GetManyDetailsByOrganizationAsync_vNext to only include Shared collections * Update comments in stored procedure and migration script to clarify filtering for SharedCollections only
66 lines
1.6 KiB
Transact-SQL
66 lines
1.6 KiB
Transact-SQL
CREATE OR ALTER PROCEDURE [dbo].[Collection_ReadByOrganizationId]
|
|
@OrganizationId UNIQUEIDENTIFIER
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON
|
|
|
|
SELECT
|
|
*
|
|
FROM
|
|
[dbo].[CollectionView]
|
|
WHERE
|
|
[OrganizationId] = @OrganizationId
|
|
END
|
|
GO
|
|
|
|
CREATE OR ALTER PROCEDURE [dbo].[Collection_ReadSharedCollectionsByOrganizationId]
|
|
@OrganizationId UNIQUEIDENTIFIER
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON
|
|
|
|
SELECT
|
|
*
|
|
FROM
|
|
[dbo].[CollectionView]
|
|
WHERE
|
|
[OrganizationId] = @OrganizationId AND
|
|
[Type] = 0 -- SharedCollections only
|
|
END
|
|
GO
|
|
|
|
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUserUserDetails_ReadByOrganizationId_V2]
|
|
@OrganizationId UNIQUEIDENTIFIER,
|
|
@IncludeGroups BIT = 0,
|
|
@IncludeCollections BIT = 0
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON
|
|
|
|
-- Result Set 1: User Details (always returned)
|
|
SELECT *
|
|
FROM [dbo].[OrganizationUserUserDetailsView]
|
|
WHERE OrganizationId = @OrganizationId
|
|
|
|
-- Result Set 2: Group associations (if requested)
|
|
IF @IncludeGroups = 1
|
|
BEGIN
|
|
SELECT gu.*
|
|
FROM [dbo].[GroupUser] gu
|
|
INNER JOIN [dbo].[OrganizationUser] ou ON gu.OrganizationUserId = ou.Id
|
|
WHERE ou.OrganizationId = @OrganizationId
|
|
END
|
|
|
|
-- Result Set 3: Collection associations (if requested)
|
|
IF @IncludeCollections = 1
|
|
BEGIN
|
|
SELECT cu.*
|
|
FROM [dbo].[CollectionUser] cu
|
|
INNER JOIN [dbo].[OrganizationUser] ou ON cu.OrganizationUserId = ou.Id
|
|
INNER JOIN [dbo].[Collection] c ON cu.CollectionId = c.Id
|
|
WHERE ou.OrganizationId = @OrganizationId
|
|
AND c.Type = 0 -- SharedCollections only
|
|
END
|
|
END
|
|
GO
|