mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
[AC-1682] Updated queries to check for OrganizationId
This commit is contained in:
parent
28bba94d81
commit
a957530d5e
@ -41,7 +41,7 @@
|
||||
SET `CG`.`ReadOnly` = 0,
|
||||
`CG`.`HidePasswords` = 0,
|
||||
`CG`.`Manage` = 0
|
||||
WHERE `C`.`OrganizationId` = `TG`.`OrganizationId`;
|
||||
WHERE `CG`.`CollectionId` = `C`.`Id` AND `C`.`OrganizationId` = `TG`.`OrganizationId`;
|
||||
|
||||
-- Insert new rows into `CollectionGroups`
|
||||
INSERT INTO `CollectionGroups` (`CollectionId`, `GroupId`, `ReadOnly`, `HidePasswords`, `Manage`)
|
||||
@ -58,13 +58,14 @@
|
||||
|
||||
-- Step 2
|
||||
-- Update existing rows in `CollectionUsers`
|
||||
UPDATE `CollectionUsers` `target`
|
||||
INNER JOIN `Collection` `C` ON `target`.`CollectionId` = `C`.`Id`
|
||||
UPDATE `CollectionUsers` `CU`
|
||||
INNER JOIN `Collection` `C` ON `CU`.`CollectionId` = `C`.`Id`
|
||||
INNER JOIN `TempUsersAccessAll` `TU`
|
||||
ON `C`.`OrganizationId` = `TU`.`OrganizationId` AND `target`.`OrganizationUserId` = `TU`.`OrganizationUserId`
|
||||
SET `target`.`ReadOnly` = 0,
|
||||
`target`.`HidePasswords` = 0,
|
||||
`target`.`Manage` = 0;
|
||||
ON `C`.`OrganizationId` = `TU`.`OrganizationId` AND `CU`.`OrganizationUserId` = `TU`.`OrganizationUserId`
|
||||
SET `CU`.`ReadOnly` = 0,
|
||||
`CU`.`HidePasswords` = 0,
|
||||
`CU`.`Manage` = 0
|
||||
WHERE `CU`.`CollectionId` = `C`.`Id`;
|
||||
|
||||
-- Insert new rows into `CollectionUsers`
|
||||
INSERT INTO `CollectionUsers` (`CollectionId`, `OrganizationUserId`, `ReadOnly`, `HidePasswords`, `Manage`)
|
||||
|
@ -40,8 +40,8 @@
|
||||
"HidePasswords" = false,
|
||||
"Manage" = false
|
||||
FROM "Collection" "C"
|
||||
WHERE "CG"."CollectionId" = "C"."Id"
|
||||
AND "C"."OrganizationId" IN (SELECT "OrganizationId" FROM "TempGroupsAccessAll");
|
||||
JOIN "TempGroupsAccessAll" "TG" ON "CG"."GroupId" = "TG"."GroupId"
|
||||
WHERE "CG"."CollectionId" = "C"."Id" AND "C"."OrganizationId" = TG."OrganizationId";
|
||||
|
||||
-- Insert new rows into CollectionGroups
|
||||
INSERT INTO "CollectionGroups" ("CollectionId", "GroupId", "ReadOnly", "HidePasswords", "Manage")
|
||||
@ -58,14 +58,14 @@
|
||||
|
||||
-- Step 2
|
||||
-- Update existing rows in CollectionUsers
|
||||
UPDATE "CollectionUsers" "target"
|
||||
UPDATE "CollectionUsers" "CU"
|
||||
SET "ReadOnly" = false,
|
||||
"HidePasswords" = false,
|
||||
"Manage" = false
|
||||
FROM "Collection" "C"
|
||||
WHERE "target"."CollectionId" = "C"."Id"
|
||||
AND "C"."OrganizationId" IN (SELECT "OrganizationId" FROM "TempUsersAccessAll")
|
||||
AND "target"."OrganizationUserId" IN (SELECT "OrganizationUserId" FROM "TempUsersAccessAll");
|
||||
INNER JOIN "TempUsersAccessAll" "TU" ON "C"."OrganizationId" = "TU"."OrganizationId" AND
|
||||
"CU"."OrganizationUserId" = "TU"."OrganizationUserId"
|
||||
WHERE "CU"."CollectionId" = "C"."Id";
|
||||
|
||||
-- Insert new rows into CollectionUsers
|
||||
INSERT INTO "CollectionUsers" ("CollectionId", "OrganizationUserId", "ReadOnly", "HidePasswords", "Manage")
|
||||
|
@ -62,16 +62,14 @@
|
||||
|
||||
-- Step 2
|
||||
-- Update existing rows in "CollectionUsers"
|
||||
UPDATE "CollectionUsers"
|
||||
SET
|
||||
"ReadOnly" = 0,
|
||||
UPDATE "CollectionUsers" "CU"
|
||||
SET "ReadOnly" = 0,
|
||||
"HidePasswords" = 0,
|
||||
"Manage" = 0
|
||||
WHERE "CollectionId" IN (
|
||||
SELECT "C"."Id"
|
||||
FROM "Collection" "C"
|
||||
INNER JOIN "TempUsersAccessAll" "TU" ON "C"."OrganizationId" = "TU"."OrganizationId"
|
||||
);
|
||||
FROM "Collection" "C"
|
||||
INNER JOIN "TempUsersAccessAll" AS "TU" ON "CU"."OrganizationUserId" = "TU"."OrganizationUserId" AND
|
||||
"C"."OrganizationId" = "TU"."OrganizationId"
|
||||
WHERE "CU"."CollectionId" = "C"."Id";
|
||||
|
||||
-- Insert new rows into "CollectionUsers"
|
||||
INSERT INTO "CollectionUsers" ("CollectionId", "OrganizationUserId", "ReadOnly", "HidePasswords", "Manage")
|
||||
|
Loading…
Reference in New Issue
Block a user