diff --git a/database/migration/deploy/new_way_delete_esp_permission.sql b/database/migration/deploy/new_way_delete_esp_permission.sql index 5081168..a42d445 100644 --- a/database/migration/deploy/new_way_delete_esp_permission.sql +++ b/database/migration/deploy/new_way_delete_esp_permission.sql @@ -6,25 +6,25 @@ BEGIN; -- Remove permission to DELETE on data and esp tables -REVOKE DELETE ON api.data FROM web_user; -REVOKE DELETE ON api.esp FROM web_user; +REVOKE DELETE ON api.data FROM web_user; -- Revoke permission for the user to DELETE datas on table DATA +REVOKE DELETE ON api.esp FROM web_user; -- Revoke permission for the user to DELETE datas on table ESP -- Add permission to DELETE on data and esp tables -GRANT DELETE ON api.data TO web_user; -GRANT DELETE ON api.esp TO web_user; +GRANT DELETE ON api.data TO web_user; -- Add permission for the user to DELETE datas on table DATA +GRANT DELETE ON api.esp TO web_user; -- Add permission for the user to DELETE datas on table ESP -- Delete the function if exists -DROP FUNCTION IF EXISTS api.delete_esp_data_and_esp(); +-- DROP FUNCTION IF EXISTS api.delete_esp_data_and_esp(); -- Create the function -CREATE FUNCTION api.delete_esp_data_and_esp() +CREATE FUNCTION api.delete_esp_data_and_esp(id INT) RETURNS VOID AS $$ BEGIN -- DELETE on data and esp tables - DELETE FROM api.data WHERE esp_id = ${id}; - DELETE FROM api.esp WHERE id = ${id}; + DELETE FROM api.data WHERE esp_id = id; + DELETE FROM api.esp WHERE id = id; END; $$ LANGUAGE plpgsql; diff --git a/database/migration/revert/add_new_permission.sql b/database/migration/revert/add_new_permission.sql index 4ea61be..fad3771 100644 --- a/database/migration/revert/add_new_permission.sql +++ b/database/migration/revert/add_new_permission.sql @@ -2,6 +2,6 @@ BEGIN; - revoke update on api.users to web_user; -- any user can edit users + revoke update on api.users from web_user; -- any user can edit users COMMIT; diff --git a/nextjs-interface/src/app/ui/dashboard/DeleteEsp.tsx b/nextjs-interface/src/app/ui/dashboard/DeleteEsp.tsx index 4579b6f..f3fada7 100644 --- a/nextjs-interface/src/app/ui/dashboard/DeleteEsp.tsx +++ b/nextjs-interface/src/app/ui/dashboard/DeleteEsp.tsx @@ -10,7 +10,6 @@ export default function DeleteEsp({ id }: { id: string }) { try { const response = await fetch(url, { headers: { - "Content-Type": "application/json", Authorization: `Bearer ${getToken()}`, }, }); @@ -33,4 +32,4 @@ export default function DeleteEsp({ id }: { id: string }) { deleteEsp(id)} /> ); -} +} \ No newline at end of file