Skip to content

Commit

Permalink
fix: some corrections
Browse files Browse the repository at this point in the history
Closes: #218
  • Loading branch information
ColinRgm committed Jan 14, 2025
1 parent 1d6d32c commit 950804b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
3 changes: 1 addition & 2 deletions database/migration/deploy/delete_esp_permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

BEGIN;

grant delete on api.esp to web_user; -- any user can delete ESP
grant delete on api.data to web_user; -- any user can delete ESP's data


COMMIT;
4 changes: 0 additions & 4 deletions database/migration/deploy/new_way_delete_esp_permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ BEGIN;
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; -- 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;

Expand Down
3 changes: 1 addition & 2 deletions database/migration/revert/delete_esp_permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

BEGIN;

revoke delete on api.esp from web_user; -- any user can't anymore delete ESP
revoke delete on api.data from web_user; -- any user can't anymore delete ESP's data


COMMIT;
8 changes: 4 additions & 4 deletions database/migration/revert/new_way_delete_esp_permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
BEGIN;


-- Remove permission to DELETE on data and esp tables
-- DELETE the function if it exists
DROP FUNCTION IF EXISTS api.delete_esp_data_and_esp(id);


grant delete on api.esp to web_user; -- any user can delete ESP
grant delete on api.data to web_user; -- any user can delete ESP's data
-- Remove permission to delete
REVOKE DELETE ON api.esp FROM web_user; -- no one can delete ESP
REVOKE DELETE ON api.data FROM web_user; -- no one can delete ESP's data


COMMIT;
4 changes: 2 additions & 2 deletions nextjs-interface/src/app/ui/dashboard/DeleteEsp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default function DeleteEsp({ id }: { id: string }) {
window.location.href = `/dashboard`;

if (!response.ok) {
console.error(`une erreur lors de la suppression de l'ESP`);
console.error(`Une erreur est survenue lors de la suppression de l'ESP`);
console.error(await response.json());
} else {
console.log("Tout bon");
console.log("ESP supprimé avec succés");
}
} catch (error) {
console.error("Error: ", error);
Expand Down

0 comments on commit 950804b

Please sign in to comment.