hey, what would be the easiest way to restrict acc...
# help
i
hey, what would be the easiest way to restrict access to view/edit supabase data based on discord roles?
n
Hello @ian_! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
i
different people add my bots to their server and for each server it will create an item in a supabase table representing the server people can login with discord and if they have certain roles in certain servers they should be able to edit, say, a todo list for that server
g
Where is the role stored?
n
ian_ (2022-05-12)
i
that's part of the question
it's in discord, the discord bot has access to who has what roles in a server
i could try keeping a supabase table in sync with the roles on the server
g
Not familiar with discord, does the role get returned, or can it, on signin in any of the metadata for the user?
i
i don't think so - because people have different roles in each server they're in. it's possible it can be but I doubt it, and it looks like supabase doesn't allow requesting info from a user
g
You can use the discord api (assuming it has one) using http extension or with an external function like the new edge functions.
If the role is not in the jwt metadata, which sounds like no, then you will need a user and roles assigned to them table that can be used in RLS. You would have to populate that table somehow though with discord role and I can not help you with that.
i
how do I use a table in RLS? i only see instructions for using the user id
looks like i just write an SQL query
g
https://supabase.com/docs/guides/auth/row-level-security. RLS policy is just a where statement added on. So yes a query that returns true.
2 Views