1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-06 13:38:13 -05:00

org enabeld check on user assets

This commit is contained in:
Kyle Spearrin 2017-04-11 10:19:19 -04:00
parent c28106c81b
commit 53a25b908a
8 changed files with 22 additions and 4 deletions

View File

@ -14,10 +14,13 @@ BEGIN
[dbo].[Cipher] C ON SC.[CipherId] = C.[Id]
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.Id = SU.OrganizationUserId AND OU.OrganizationId = C.OrganizationId
INNER JOIN
[dbo].[Organization] O ON O.Id = C.OrganizationId
WHERE
C.[Id] = @CipherId
AND OU.[UserId] = @UserId
AND OU.[Status] = 2 -- 2 = Confirmed
AND O.[Enabled] = 1
)
SELECT
@CanEdit = CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END

View File

@ -15,10 +15,12 @@ BEGIN
[dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId]
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = SU.[OrganizationUserId]
LEFT JOIN
[dbo].[Organization] O ON O.[Id] = C.[OrganizationId]
WHERE
C.Id = @Id
AND (
(C.[UserId] IS NOT NULL AND C.[UserId] = @UserId)
OR (OU.[UserId] = @UserId AND OU.[Status] = 2) -- 2 = Confirmed
OR (OU.[UserId] = @UserId AND OU.[Status] = 2 AND O.[Enabled] = 1) -- 2 = Confirmed
)
END

View File

@ -15,10 +15,12 @@ BEGIN
[dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId]
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = SU.[OrganizationUserId]
LEFT JOIN
[dbo].[Organization] O ON O.[Id] = C.[OrganizationId]
WHERE
C.[Type] = @Type
AND (
(C.[UserId] IS NOT NULL AND C.[UserId] = @UserId)
OR (OU.[UserId] = @UserId AND OU.[Status] = 2) -- 2 = Confirmed
OR (OU.[UserId] = @UserId AND OU.[Status] = 2 AND O.[Enabled] = 1) -- 2 = Confirmed
)
END

View File

@ -14,7 +14,9 @@ BEGIN
[dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId]
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = SU.[OrganizationUserId]
LEFT JOIN
[dbo].[Organization] O ON O.[Id] = C.[OrganizationId]
WHERE
(C.[UserId] IS NOT NULL AND C.[UserId] = @UserId)
OR (OU.[UserId] = @UserId AND OU.[Status] = 2) -- 2 = Confirmed
OR (OU.[UserId] = @UserId AND OU.[Status] = 2 AND O.[Enabled] = 1) -- 2 = Confirmed
END

View File

@ -14,7 +14,10 @@ BEGIN
[dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId]
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = SU.[OrganizationUserId]
INNER JOIN
[dbo].[Organization] O ON O.[Id] = C.[OrganizationId]
WHERE
OU.[UserId] = @UserId
AND OU.[Status] = 2 -- 2 = Confirmed
AND O.[Enabled] = 1
END

View File

@ -19,10 +19,12 @@ BEGIN
[dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId]
LEFT JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = SU.[OrganizationUserId]
LEFT JOIN
[dbo].[Organization] O ON O.[Id] = C.[OrganizationId]
WHERE
C.Id = @Id
AND (
(C.[UserId] IS NOT NULL AND C.[UserId] = @UserId)
OR (OU.[UserId] = @UserId AND OU.[Status] = 2) -- 2 = Confirmed
OR (OU.[UserId] = @UserId AND OU.[Status] = 2 AND O.[Enabled] = 1) -- 2 = Confirmed
)
END

View File

@ -12,7 +12,10 @@ BEGIN
[SubvaultUser] SU ON SU.[SubvaultId] = S.[Id]
INNER JOIN
[OrganizationUser] OU ON OU.[Id] = SU.[OrganizationUserId]
INNER JOIN
[Organization] O ON O.[Id] = OU.[OrganizationId]
WHERE
OU.[UserId] = @UserId
AND OU.[Status] = 2 -- Confirmed
AND O.[Enabled] = 1
END

View File

@ -4,6 +4,7 @@ SELECT
OU.[UserId],
OU.[OrganizationId],
O.[Name],
O.[Enabled],
OU.[Key],
OU.[Status],
OU.[Type]