mirror of
https://github.com/bitwarden/server.git
synced 2025-07-17 07:30:59 -05:00
rename AccessAllCollections => AccessAll
This commit is contained in:
@ -5,7 +5,7 @@ BEGIN
|
||||
|
||||
;WITH [CTE] AS(
|
||||
SELECT
|
||||
CASE WHEN OU.[AccessAllCollections] = 1 OR CU.[ReadOnly] = 0 THEN 1 ELSE 0 END [CanEdit]
|
||||
CASE WHEN OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0 THEN 1 ELSE 0 END [CanEdit]
|
||||
FROM
|
||||
[dbo].[Cipher] C
|
||||
INNER JOIN
|
||||
@ -13,14 +13,14 @@ BEGIN
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
C.[Id] = @CipherId
|
||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||
AND O.[Enabled] = 1
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
)
|
||||
SELECT
|
||||
@CanEdit = CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END
|
||||
|
@ -14,7 +14,7 @@ BEGIN
|
||||
LEFT JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
@ -25,7 +25,7 @@ BEGIN
|
||||
C.[UserId] IS NULL
|
||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||
AND O.[Enabled] = 1
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
)
|
||||
)
|
||||
END
|
@ -14,7 +14,7 @@ BEGIN
|
||||
LEFT JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
@ -25,7 +25,7 @@ BEGIN
|
||||
C.[UserId] IS NULL
|
||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||
AND O.[Enabled] = 1
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
)
|
||||
)
|
||||
END
|
@ -13,7 +13,7 @@ BEGIN
|
||||
LEFT JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
@ -22,6 +22,6 @@ BEGIN
|
||||
C.[UserId] IS NULL
|
||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||
AND O.[Enabled] = 1
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
)
|
||||
END
|
@ -13,11 +13,11 @@ BEGIN
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
OU.[Status] = 2 -- 2 = Confirmed
|
||||
AND O.[Enabled] = 1
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
END
|
@ -18,7 +18,7 @@ BEGIN
|
||||
LEFT JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
@ -29,7 +29,7 @@ BEGIN
|
||||
C.[UserId] IS NULL
|
||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||
AND O.[Enabled] = 1
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
)
|
||||
)
|
||||
END
|
@ -34,12 +34,12 @@ BEGIN
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
O.[Id] = @OrganizationId
|
||||
AND O.[Enabled] = 1
|
||||
AND OU.[Status] = 2 -- Confirmed
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[ReadOnly] = 0)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0)
|
||||
)
|
||||
INSERT INTO [dbo].[CollectionCipher]
|
||||
(
|
||||
|
@ -13,8 +13,8 @@ BEGIN
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
OU.[Status] = 2 -- Confirmed
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
END
|
@ -14,9 +14,9 @@ BEGIN
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
SC.[CipherId] = @CipherId
|
||||
AND OU.[Status] = 2 -- Confirmed
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
END
|
@ -25,12 +25,12 @@ BEGIN
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
O.[Id] = @OrgId
|
||||
AND O.[Enabled] = 1
|
||||
AND OU.[Status] = 2 -- Confirmed
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[ReadOnly] = 0)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0)
|
||||
)
|
||||
MERGE
|
||||
[dbo].[CollectionCipher] AS [Target]
|
||||
|
@ -9,6 +9,6 @@ BEGIN
|
||||
FROM
|
||||
[dbo].[CollectionUserUserDetailsView]
|
||||
WHERE
|
||||
[AccessAllCollections] = 1
|
||||
[AccessAll] = 1
|
||||
OR [CollectionId] = @CollectionId
|
||||
END
|
@ -13,9 +13,9 @@ BEGIN
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = S.[Id] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
OU.[Status] = 2 -- Confirmed
|
||||
AND O.[Enabled] = 1
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
END
|
@ -18,14 +18,14 @@ BEGIN
|
||||
LEFT JOIN
|
||||
[dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND CC.[CipherId] = C.[Id]
|
||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 0 AND CC.[CipherId] = C.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||
WHERE
|
||||
C.[UserId] = @UserId
|
||||
OR (
|
||||
C.[UserId] IS NULL
|
||||
AND (OU.[AccessAllCollections] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
AND (OU.[AccessAll] = 1 OR CU.[CollectionId] IS NOT NULL)
|
||||
)
|
||||
AND C.[Folders] IS NOT NULL
|
||||
AND JSON_VALUE(C.[Folders], @UserIdPath) = @Id
|
||||
|
@ -6,7 +6,7 @@
|
||||
@Key VARCHAR(MAX),
|
||||
@Status TINYINT,
|
||||
@Type TINYINT,
|
||||
@AccessAllCollections BIT,
|
||||
@AccessAll BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
AS
|
||||
@ -22,7 +22,7 @@ BEGIN
|
||||
[Key],
|
||||
[Status],
|
||||
[Type],
|
||||
[AccessAllCollections],
|
||||
[AccessAll],
|
||||
[CreationDate],
|
||||
[RevisionDate]
|
||||
)
|
||||
@ -35,7 +35,7 @@ BEGIN
|
||||
@Key,
|
||||
@Status,
|
||||
@Type,
|
||||
@AccessAllCollections,
|
||||
@AccessAll,
|
||||
@CreationDate,
|
||||
@RevisionDate
|
||||
)
|
||||
|
@ -6,7 +6,7 @@
|
||||
@Key VARCHAR(MAX),
|
||||
@Status TINYINT,
|
||||
@Type TINYINT,
|
||||
@AccessAllCollections BIT,
|
||||
@AccessAll BIT,
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7)
|
||||
AS
|
||||
@ -22,7 +22,7 @@ BEGIN
|
||||
[Key] = @Key,
|
||||
[Status] = @Status,
|
||||
[Type] = @Type,
|
||||
[AccessAllCollections] = @AccessAllCollections,
|
||||
[AccessAll] = @AccessAll,
|
||||
[CreationDate] = @CreationDate,
|
||||
[RevisionDate] = @RevisionDate
|
||||
WHERE
|
||||
|
@ -6,7 +6,7 @@
|
||||
[Key] VARCHAR (MAX) NULL,
|
||||
[Status] TINYINT NOT NULL,
|
||||
[Type] TINYINT NOT NULL,
|
||||
[AccessAllCollections] BIT NOT NULL,
|
||||
[AccessAll] BIT NOT NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[RevisionDate] DATETIME2 (7) NOT NULL,
|
||||
CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
|
@ -2,17 +2,17 @@
|
||||
AS
|
||||
SELECT
|
||||
OU.[Id] AS [OrganizationUserId],
|
||||
OU.[AccessAllCollections],
|
||||
OU.[AccessAll],
|
||||
CU.[Id],
|
||||
CU.[CollectionId],
|
||||
U.[Name],
|
||||
ISNULL(U.[Email], OU.[Email]) Email,
|
||||
OU.[Status],
|
||||
OU.[Type],
|
||||
CASE WHEN OU.[AccessAllCollections] = 0 AND CU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
|
||||
CASE WHEN OU.[AccessAll] = 0 AND CU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
|
||||
FROM
|
||||
[dbo].[OrganizationUser] OU
|
||||
LEFT JOIN
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAllCollections] = 0 AND CU.[OrganizationUserId] = OU.[Id]
|
||||
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[OrganizationUserId] = OU.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[User] U ON U.[Id] = OU.[UserId]
|
@ -8,7 +8,7 @@ SELECT
|
||||
ISNULL(U.[Email], OU.[Email]) Email,
|
||||
OU.[Status],
|
||||
OU.[Type],
|
||||
OU.[AccessAllCollections]
|
||||
OU.[AccessAll]
|
||||
FROM
|
||||
[dbo].[OrganizationUser] OU
|
||||
LEFT JOIN
|
||||
|
Reference in New Issue
Block a user