Hey everyone! I'm reasonably new to Postgres + sup...
# help
t
Hey everyone! I'm reasonably new to Postgres + supabase. I'm wondering if there's an easy way to assign a role other than "authenticated" to a user either on creation, or using the GUI. I see all the roles listed under "Database / Roles" in the GUI but whenever I call the supabase signUp function the role is automatically assigned to "authenticated" and I see no way of assigning an alternate role in the API Reference. If anyone could point me to the appropriate documentation or provide a solution that would be great! Thanks
s
I'm curious - what's your use case for needing a different role for users?
t
Well, maybe i'm misinterpreting what those roles are supposed to be used for. I'm really just looking to be able to distinguish 'admin' accounts from just basic 'user' accounts, I was thinking of using the 'role' field to do this. Am I completely wrong?
s
The roles in the DB shouldn't be considered equivalent to roles within your application. The
authenticated
role indicates only that the user can access the platform, and I believe it's setup to prevent users doing really dangerous things (like dropping tables). In general, you don't want anyone who's logging into the database to be anything except
authenticated
. One solution to have 'roles' within your application would be to create a
roles
table with the various permissions you need. For example, if you're making a blog website with people who can add content, edit content and delete content, you'd have
can_add
,
can_edit
, and
can_delete
columns. You might then have a
public.users
table which has a
belongs_to_group
column which is linked to the
roles
table.
t
Yeah that sounds like a better idea. Thanks for that Scott