S
Supabase2mo ago
Ak

How do I make myself admin on my site?

I have been struggling to make myself admin on my site so I have the powers to manage accounts. Does anyone know how to do this?
9 Replies
garyaustin
garyaustin2mo ago
You need to be clearer on what you are asking about. Is the for the Supabase dashboard or for your app? There is no special admin for the dashboard beyond the default when you signup. If your app then you have to come up with a way to create a role for users either in a table or using the JWT with app_metadata or a custom claim.
Ak
AkOP2mo ago
yes its for my app. I was using the ai on Supabase but Im not sure If I got it. Do you have step by step directions on it, please?
garyaustin
garyaustin2mo ago
There are no step by step directions. There are many ways of doing and lots of user examples on the web. Supabase has custom claims hook as the main way they show for adding a role setting to the JWT. https://supabase.com/docs/guides/database/postgres/custom-claims-and-role-based-access-control-rbac https://supabase.com/docs/guides/auth/auth-hooks/custom-access-token-hook?queryGroups=language&language=http
Ak
AkOP2mo ago
The step I took was that I went to Table Editor scrolled to role and selected admin. Is that right?
garyaustin
garyaustin2mo ago
No idea what that means. There is no default admin/role table. Did you use one the RBAC guide or another guide?
Ak
AkOP2mo ago
I asked the AI
garyaustin
garyaustin2mo ago
OK. That is no help. No idea what the AI did or told you.
What do you mean you scrolled to role and selected admin? Did you create a role table?
Ak
AkOP2mo ago
When you go to Table Editor I created a table called profiles. It must have been when I used the Supabase ai and ran a query that it added information in it. Then if you scroll right there is a section called roles. I selected edit and set the user role under my email as admin.
garyaustin
garyaustin2mo ago
A profile table could be used to get the role and with the code I linked put in the JWT. Or you could theoretically use your profile table in RLS to check the role column with auth.uid() to control access to the user's profile row. Either way you would then write RLS policies that allow the access you want.
Adding a role to a profile table you created in and of itself does nothing. There is no such thing as an admin role in Supabase so it is all up to you how you define and use it.

Did you find this page helpful?