1
0
mirror of https://github.com/bitwarden/server synced 2026-01-05 18:13:31 +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

@@ -1,18 +0,0 @@
CREATE VIEW [dbo].[CollectionUserCollectionDetailsView]
AS
SELECT
C.[Id] Id,
C.[OrganizationId],
C.[Name],
OU.[UserId],
OU.[Id] AS [OrganizationUserId],
CASE WHEN OU.[AccessAll] = 0 AND CU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
FROM
[dbo].[Collection] C
INNER JOIN
[dbo].[OrganizationUser] OU ON C.[OrganizationId] = OU.[OrganizationId]
LEFT JOIN
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = C.[Id] AND CU.[OrganizationUserId] = [OU].[Id]
WHERE
OU.[AccessAll] = 1
OR CU.[Id] IS NOT NULL

View File

@@ -10,10 +10,19 @@ SELECT
ISNULL(U.[Email], OU.[Email]) Email,
OU.[Status],
OU.[Type],
CASE WHEN OU.[AccessAll] = 0 AND CU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
CASE
WHEN OU.[AccessAll] = 0 AND CU.[ReadOnly] = 1 AND G.[AccessAll] = 0 AND CG.[ReadOnly] = 1 THEN 1
ELSE 0
END [ReadOnly]
FROM
[dbo].[OrganizationUser] OU
LEFT JOIN
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[OrganizationUserId] = OU.[Id]
LEFT JOIN
[dbo].[User] U ON U.[Id] = OU.[UserId]
[dbo].[User] U ON U.[Id] = OU.[UserId]
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.[GroupId] = GU.[GroupId]