mirror of
https://github.com/bitwarden/server
synced 2025-12-28 22:23:30 +00:00
* do not follow local hosts or ip addresses * remove cron from mssql * migration script * Use joins instead of temp tables * update migration script with join changes
34 lines
1.1 KiB
Transact-SQL
34 lines
1.1 KiB
Transact-SQL
CREATE PROCEDURE [dbo].[User_BumpAccountRevisionDateByCollectionId]
|
|
@CollectionId UNIQUEIDENTIFIER,
|
|
@OrganizationId UNIQUEIDENTIFIER
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON
|
|
|
|
UPDATE
|
|
U
|
|
SET
|
|
U.[AccountRevisionDate] = GETUTCDATE()
|
|
FROM
|
|
[dbo].[User] U
|
|
INNER JOIN
|
|
[dbo].[OrganizationUser] OU ON OU.[UserId] = U.[Id]
|
|
LEFT JOIN
|
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[OrganizationUserId] = OU.[Id] AND CU.[CollectionId] = @CollectionId
|
|
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] AND CG.[CollectionId] = @CollectionId
|
|
WHERE
|
|
OU.[OrganizationId] = @OrganizationId
|
|
AND OU.[Status] = 2 -- 2 = Confirmed
|
|
AND (
|
|
CU.[CollectionId] IS NOT NULL
|
|
OR CG.[CollectionId] IS NOT NULL
|
|
OR OU.[AccessAll] = 1
|
|
OR G.[AccessAll] = 1
|
|
)
|
|
END
|