RLS policy for linking two tables in query

I have a Table:

Table public.users {
  user_id, //links to table auth.user.id
  role,    //admin, super_admin, user
  email    //links to table auth.users.email
}


I'm Trying to create a policy that allows auth.uid() to edit this table if his role is admin of super_admin

I've come up with:

create policy admin_can_edit_policy 
    on public.users
    for update using ( 
        auth.uid() in ( 
            select role from public.users 
                where user_id = auth.uid() 
                and (
                    role = 'admin' 
                    or role = 'super_admin'
                )
                limit 1
        )
    );


Not sure why I'm getting syntax errors. Does someone have any insights for me?
Was this page helpful?