Reputation: 1
I'm new to Supabase(PostgreSQL) and struggling with writing RLS. I have 'users' and 'roles' tables. There are 5 roles - SUPER_ADMIN, ADMIN, CLIENT, SPECIALIST, INTERNAL_OPERATOR. Now, I'm going to write RLS on 'users' table so only users with SUPER_ADMIN role can do CRUD users. 'users' and 'roles' tables has relationship based on role_id in 'users' table.
Please help me.
CREATE POLICY "Allow SUPER_ADMIN access"
ON users
FOR ALL
USING (
EXISTS (
SELECT 1
FROM roles
WHERE roles.id = users.role_id
AND roles.name = 'SUPER_ADMIN'
)
);
I wrote like this. But when I log in with SUPER_ADMIN role, I'm only fetchings users who has SUPER_ADMIN role
Upvotes: 0
Views: 56