Skip to content

Commit

Permalink
Merge pull request #219 from CirclesUBI/feature/app-450-add-possibili…
Browse files Browse the repository at this point in the history
…ty-for-db-admin-to-disable-an-account-FINAL

fixing stored procedure to disable users
  • Loading branch information
jaensen authored Sep 7, 2023
2 parents 7be4e22 + 39fb3ec commit 44126e7
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@o-platform/api-server",
"version": "1.0.5",
"version": "1.0.5-1",
"description": "",
"main": "dist/index.js",
"prepublish": "tsc",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
-- migrate:up
CREATE OR REPLACE PROCEDURE sp_DisableProfileAndShop(address varchar(100))
LANGUAGE plpgsql
AS $$
BEGIN
-- Remove Session
DELETE FROM "Session"
WHERE "Session"."profileId" IN(
SELECT
"id"
FROM
"Profile"
WHERE
"circlesAddress" = address);
-- Copy circlesAddress to disabledCirclesAddress
UPDATE
"Profile"
SET
"disabledCirclesAddress" = "circlesAddress"
WHERE
"circlesAddress" = address;
-- Copy circlesSafeOwner to disabledCirclesSafeOwner
UPDATE
"Profile"
SET
"disabledCirclesSafeOwner" = "circlesSafeOwner"
WHERE
"circlesAddress" = address;
-- Set disabled status
UPDATE
"Profile"
SET
"status" = 'disabled'
WHERE
"circlesAddress" = address;
-- Disable the Shop for the Person Entry
UPDATE
"Profile"
SET
"shopEnabled" = FALSE
WHERE
"circlesAddress" = address;
-- Remove circlesSafeOwner
UPDATE
"Profile"
SET
"circlesSafeOwner" = NULL
WHERE
"circlesAddress" = address;
-- Remove CirclesAddress
UPDATE
"Profile"
SET
"circlesAddress" = NULL
WHERE
"circlesAddress" = address;
-- Disable the Shop for the Orga Entry
UPDATE
"Profile"
SET
"shopEnabled" = FALSE
WHERE
id IN(
SELECT
"createdByProfileId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
-- copy circlesAddress for the Orga Entry
UPDATE
"Profile"
SET
"disabledCirclesAddress" = "circlesAddress"
WHERE
id IN(
SELECT
"memberAtId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
-- Remove circlesAddress for Orga Entry
UPDATE
"Profile"
SET
"circlesAddress" = NULL
WHERE
id IN(
SELECT
"memberAtId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
-- set status for Orga Entry to disabled
UPDATE
"Profile"
SET
"status" = 'disabled'
WHERE
id IN(
SELECT
"memberAtId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
END
$$
-- migrate:down

0 comments on commit 44126e7

Please sign in to comment.