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>
28 lines
819 B
SQL
28 lines
819 B
SQL
-- Allow RV renters/owners to discover and self-link a rental that was created
|
|
-- with their email but never had user_id set yet. This supports the renter
|
|
-- portal's email-based fallback (renters often have no owners record).
|
|
|
|
CREATE POLICY "RV renters can view rental matching their email"
|
|
ON public.rv_boat_lot_rentals
|
|
FOR SELECT
|
|
TO authenticated
|
|
USING (
|
|
user_id IS NULL
|
|
AND status = 'active'
|
|
AND renter_email IS NOT NULL
|
|
AND lower(renter_email) = lower(coalesce((auth.jwt() ->> 'email'), ''))
|
|
);
|
|
|
|
CREATE POLICY "RV renters can self-link rental by email"
|
|
ON public.rv_boat_lot_rentals
|
|
FOR UPDATE
|
|
TO authenticated
|
|
USING (
|
|
user_id IS NULL
|
|
AND status = 'active'
|
|
AND renter_email IS NOT NULL
|
|
AND lower(renter_email) = lower(coalesce((auth.jwt() ->> 'email'), ''))
|
|
)
|
|
WITH CHECK (
|
|
user_id = auth.uid()
|
|
); |