O/ question, I want to have 3 types of users: admi...
# off-topic
r
O/ question, I want to have 3 types of users: admin, instructor, and student. Instructors would have the ability to upload content (aka insert) and admins can manage it (update, delete). How would I achieve this with RLS?
h
Hey! RLS is just a function that returns a bool, so you could check if a select statement in the users table for the userid and role is a match if not then return false else its true?
r
How would I do the select part?
if (select role from roles where uid = auth.uid() limit 1) = 'instructor'
Does that sound correct
p
exists(select 1 from roles where uid=auth.uid() and role='instructor')
r
Thanks a lot!
slight change to it
Copy code
sql
exists(select 1 from profiles where uid=auth.uid() and (is_instructor=true or is_admin=true))
that should too work right?
h
does that select statement work on it's own?
r
I think so