1
0
mirror of https://github.com/bitwarden/server synced 2026-01-16 07:23:15 +00:00

Group access & sproc/model refactoring.

This commit is contained in:
Kyle Spearrin
2017-05-11 10:32:25 -04:00
parent 76cebdd886
commit f0d7dc8023
26 changed files with 238 additions and 183 deletions

View File

@@ -6,17 +6,28 @@ BEGIN
SET NOCOUNT ON
SELECT
SC.*
CC.*
FROM
[dbo].[CollectionCipher] SC
[dbo].[CollectionCipher] CC
INNER JOIN
[dbo].[Collection] S ON S.[Id] = SC.[CollectionId]
[dbo].[Collection] S ON S.[Id] = CC.[CollectionId]
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
LEFT JOIN
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
LEFT JOIN
[dbo].[GroupUser] GU ON CU.[CollectionId] IS NULL AND OU.[AccessAll] = 0 AND GU.[OrganizationUserId] = OU.[Id]
LEFT JOIN
[dbo].[Group] G ON G.[Id] = GU.[GroupId]
LEFT JOIN
[dbo].[CollectionGroup] CG ON G.[AccessAll] = 0 AND CG.[CollectionId] = CC.[CollectionId] AND CG.[GroupId] = GU.[GroupId]
WHERE
SC.[CipherId] = @CipherId
CC.[CipherId] = @CipherId
AND OU.[Status] = 2 -- Confirmed
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
AND (
OU.[AccessAll] = 1
OR CU.[CollectionId] IS NOT NULL
OR G.[AccessAll] = 1
OR CG.[CollectionId] IS NOT NULL
)
END