How to implement custom user roles in JWT, and aut...
# help
i
How to implement custom user roles in JWT, and auth.users ? To write policies like that:
Copy code
create policy "Only CUSTOM_ROLE can create posts" on posts for
    select using (auth.role() = 'CUSTOM_ROLE');
How to change role column in auth.users ?
Solved it with this approach:
Copy code
(
  EXISTS (
    SELECT *
    FROM
      users
    WHERE
      (
        (users.id = uid())
        AND ((users.role):: text = 'ADMIN':: text)
      )
  )
)
Need public.users table with the same id as in auth.users. https://supabase.io/docs/guides/auth/managing-user-data But why we need to stuff like this? Why not do it like in Hasura? User role is added to JWT claim? @User