feat: restrict inviting and removing users to workspace admins

This commit is contained in:
Henry
2025-03-24 19:10:47 +00:00
parent 05c4de153e
commit f1600793b2
2 changed files with 23 additions and 12 deletions

View File

@@ -118,6 +118,17 @@ AS $$
);
$$;
CREATE OR REPLACE FUNCTION is_workspace_member(user_id UUID, workspace_id BIGINT)
RETURNS BOOLEAN
LANGUAGE SQL
AS $$
SELECT EXISTS (
SELECT 1
FROM workspace_members
WHERE "userId" = user_id AND "workspaceId" = workspace_id
);
$$;
alter table "_card_labels" enable row level security;
alter table "_card_workspace_members" enable row level security;
alter table "_card_activity" enable row level security;
@@ -676,7 +687,7 @@ FOR SELECT
TO authenticated
USING (
"userId" = auth.uid() OR
is_workspace_admin(auth.uid(), "workspaceId")
is_workspace_member(auth.uid(), "workspaceId")
);
CREATE POLICY "Allow admins to add workspace members"