i have a quick question if anyone is up for it: in my table i have a "userType" column and they will either be clients or admins, do you know if it would be possible to write a policy to allow only users who are "admins" to edit other users?
b
burggraf
08/13/2021, 12:00 AM
Yes, this is possible. RLS policies are just SQL, so if you write a SQL statement that results in
true
or
false
you can use that as your security policy.
burggraf
08/13/2021, 12:00 AM
uid()
returns the id of the currently logged in user.
d
dailylurker
08/13/2021, 7:21 AM
I implemented this same logic in my code for now it's only for read, a few days ago I asked about this since I am getting a recursion as I am referring to the same table burggraf and another one helped me by pointing me to create a function to call below is my code
(
(company_id IN ( SELECT same_company_check(uid()) AS same_company_check))
AND
(uid() IN ( SELECT isadmin(companies.company_id) AS isadmin))
)