feat: public split visibility, RLS recursion fixes, and consolidated tasting permission management
- Added public discovery section for active splits on the landing page - Refactored split detail page for guest support and login redirects - Extracted SplitCard component for reuse - Consolidated RLS policies for bottles and tastings to resolve permission errors - Added unified SQL consolidation script for RLS and naming fixes - Enhanced service logging for better database error diagnostics
This commit is contained in:
33
enable_public_split_access.sql
Normal file
33
enable_public_split_access.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- ============================================
|
||||
-- Enable Public Access for Bottle Splits
|
||||
-- ============================================
|
||||
-- This script enables unauthenticated users (guests) to view:
|
||||
-- 1. Profiles (to see hostnames)
|
||||
-- 2. Bottle Splits (if is_active = true)
|
||||
-- 3. Split Participants (to see progress bar data)
|
||||
-- ============================================
|
||||
|
||||
-- 1. Profiles: Allow anyone to see usernames and avatars
|
||||
DROP POLICY IF EXISTS "profiles_select_policy" ON profiles;
|
||||
CREATE POLICY "profiles_select_policy" ON profiles
|
||||
FOR SELECT USING (true);
|
||||
|
||||
-- 2. Bottle Splits: Allow guests to see active splits
|
||||
-- This policy allows anyone to read splits that are marked as active.
|
||||
DROP POLICY IF EXISTS "bottle_splits_public_select" ON bottle_splits;
|
||||
CREATE POLICY "bottle_splits_public_select" ON bottle_splits
|
||||
FOR SELECT USING (is_active = true);
|
||||
|
||||
-- 3. Split Participants: Allow guests to see progress of active splits
|
||||
-- This is necessary to calculate the "taken" volume in the progress bar.
|
||||
DROP POLICY IF EXISTS "split_participants_public_select" ON split_participants;
|
||||
CREATE POLICY "split_participants_public_select" ON split_participants
|
||||
FOR SELECT USING (
|
||||
EXISTS (
|
||||
SELECT 1 FROM public.bottle_splits
|
||||
WHERE id = split_participants.split_id AND is_active = true
|
||||
)
|
||||
);
|
||||
|
||||
-- Note: Ensure "bottles_select_policy" in rls_public_bottle_access.sql
|
||||
-- is also applied to allow guests to see bottle details for active splits.
|
||||
Reference in New Issue
Block a user