mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 01:40:01 +00:00
183fe0a93c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
19 lines
513 B
SQL
19 lines
513 B
SQL
DROP POLICY IF EXISTS "Homeowners can view association documents" ON public.documents;
|
|
|
|
CREATE POLICY "Homeowners can view shared association documents"
|
|
ON public.documents
|
|
FOR SELECT
|
|
TO authenticated
|
|
USING (
|
|
public.has_role(auth.uid(), 'homeowner'::public.app_role)
|
|
AND association_id IN (
|
|
SELECT o.association_id
|
|
FROM public.owners o
|
|
WHERE o.user_id = auth.uid()
|
|
)
|
|
AND (
|
|
is_public = true
|
|
OR visibility @> ARRAY['homeowner']::text[]
|
|
OR visibility @> ARRAY['public']::text[]
|
|
)
|
|
); |