Add collaborator page

This commit is contained in:
Thilo Hohlt
2024-08-05 19:33:35 +02:00
parent 62db2776a7
commit 9f948ba0d4
11 changed files with 470 additions and 173 deletions

View File

@@ -1,4 +1,11 @@
-- migrate:up
CREATE VIEW api.account
WITH (security_invoker = on)
AS
SELECT id, username
FROM internal.user
WHERE id = (current_setting('request.jwt.claims', true)::json->>'user_id')::UUID;
CREATE VIEW api.user
WITH (security_invoker = on)
AS
@@ -151,6 +158,7 @@ GRANT EXECUTE ON FUNCTION api.create_website(VARCHAR(10), VARCHAR(50)) TO authen
-- Security invoker only works on views if the user has access to the underlying table
GRANT SELECT ON internal.user TO authenticated_user;
GRANT SELECT ON api.account TO authenticated_user;
GRANT SELECT ON api.user TO authenticated_user;
GRANT SELECT, UPDATE, DELETE ON internal.website TO authenticated_user;
GRANT SELECT, UPDATE, DELETE ON api.website TO authenticated_user;
@@ -193,4 +201,5 @@ DROP VIEW api.header;
DROP VIEW api.settings;
DROP VIEW api.media;
DROP VIEW api.website;
DROP VIEW api.user;
DROP VIEW api.user;
DROP VIEW api.account;