espace-paie-odentas/supabase/migrations/alternative_policy.sql
2025-10-12 17:05:46 +02:00

23 lines
No EOL
892 B
SQL

-- Solution alternative: politique basée sur l'email si nécessaire
-- À exécuter SEULEMENT si le diagnostic montre un problème avec auth.uid()
-- Vérifier d'abord la structure complète de staff_users
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name = 'staff_users'
AND table_schema = 'public';
-- Si staff_users a une colonne email, on peut utiliser cette politique alternative :
-- DROP POLICY IF EXISTS "Staff can view all email logs" ON email_logs;
--
-- CREATE POLICY "Staff can view all email logs" ON email_logs
-- FOR SELECT
-- TO authenticated
-- USING (
-- EXISTS (
-- SELECT 1 FROM staff_users
-- INNER JOIN auth.users ON auth.users.id = staff_users.user_id
-- WHERE auth.users.email = (SELECT email FROM auth.users WHERE id = auth.uid())
-- AND staff_users.is_staff = true
-- )
-- );