mirror of
https://github.com/bitwarden/server.git
synced 2025-04-07 05:58:13 -05:00
fixes to can edit sproc
This commit is contained in:
parent
21d1cd6adc
commit
76664c8427
@ -5,11 +5,12 @@ AS
|
|||||||
BEGIN
|
BEGIN
|
||||||
SET NOCOUNT ON
|
SET NOCOUNT ON
|
||||||
|
|
||||||
|
DECLARE @CanEdit BIT
|
||||||
|
|
||||||
|
;WITH [CTE] AS (
|
||||||
SELECT
|
SELECT
|
||||||
(
|
|
||||||
SELECT TOP 1
|
|
||||||
CASE
|
CASE
|
||||||
WHEN C.[UserId] IS NOT NULL OR OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0 THEN 1
|
WHEN C.[UserId] IS NOT NULL OR OU.[AccessAll] = 1 OR CU.[ReadOnly] = 0 OR G.[AccessAll] = 1 OR CG.[ReadOnly] = 0 THEN 1
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END [Edit]
|
END [Edit]
|
||||||
FROM
|
FROM
|
||||||
@ -22,6 +23,12 @@ BEGIN
|
|||||||
[dbo].[CollectionCipher] CC ON C.[UserId] IS NULL AND OU.[AccessAll] = 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
|
LEFT JOIN
|
||||||
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
[dbo].[CollectionUser] CU ON CU.[CollectionId] = CC.[CollectionId] AND CU.[OrganizationUserId] = OU.[Id]
|
||||||
|
LEFT JOIN
|
||||||
|
[dbo].[GroupUser] GU ON C.[UserId] IS NULL AND 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
|
WHERE
|
||||||
C.Id = @Id
|
C.Id = @Id
|
||||||
AND (
|
AND (
|
||||||
@ -30,10 +37,24 @@ BEGIN
|
|||||||
C.[UserId] IS NULL
|
C.[UserId] IS NULL
|
||||||
AND OU.[Status] = 2 -- 2 = Confirmed
|
AND OU.[Status] = 2 -- 2 = Confirmed
|
||||||
AND O.[Enabled] = 1
|
AND O.[Enabled] = 1
|
||||||
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
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
ORDER BY
|
|
||||||
[Edit] DESC
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
@CanEdit = CASE
|
||||||
|
WHEN COUNT(1) > 0 THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END
|
||||||
|
FROM
|
||||||
|
[CTE]
|
||||||
|
WHERE
|
||||||
|
[Edit] = 1
|
||||||
|
|
||||||
|
SELECT @CanEdit
|
||||||
END
|
END
|
Loading…
x
Reference in New Issue
Block a user