Extended team visibility RLS
X-Lovable-Edit-ID: edt-dba45e43-417d-4bda-8923-242eb61f0af6 Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
-- Allow team members (and originating attorney) to view and update their cases
|
||||
DROP POLICY IF EXISTS cases_select_assigned ON public.cases;
|
||||
DROP POLICY IF EXISTS cases_update_assigned ON public.cases;
|
||||
|
||||
CREATE POLICY cases_select_assigned ON public.cases
|
||||
FOR SELECT
|
||||
USING (
|
||||
public.is_admin(auth.uid())
|
||||
OR assigned_attorney_id = auth.uid()
|
||||
OR created_by = auth.uid()
|
||||
OR originating_attorney_id = auth.uid()
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM public.case_team_members tm
|
||||
WHERE tm.case_id = cases.id AND tm.user_id = auth.uid()
|
||||
)
|
||||
);
|
||||
|
||||
CREATE POLICY cases_update_assigned ON public.cases
|
||||
FOR UPDATE
|
||||
USING (
|
||||
public.is_admin(auth.uid())
|
||||
OR assigned_attorney_id = auth.uid()
|
||||
OR created_by = auth.uid()
|
||||
OR originating_attorney_id = auth.uid()
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM public.case_team_members tm
|
||||
WHERE tm.case_id = cases.id AND tm.user_id = auth.uid()
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user