Assigning user roles on registration - 2 roles, 2 registration forms (Supabase/Weweb)

Hi all - big fan of weweb/ supabase combo so far. everything has smooth sailing, but ive been stuck on this problem for a while

This project has 2 users roles (Advisors, Clients) with 2 dedicated registration forms.

Roles, UserRoles, UserProfile tables are all set up, which means its possible to manually allocate a User the correct role. My question is there a way to automate this? eg, When a user signs up through a Advisor-registration form/ Client-registration form, they are automatically assign those roles.

Considered a function/trigger in supabase to allocate role, but there seem to be no way to communicate which form the user registered from. I may be wrong, but this seems to indicate the workflow needs to be created on the app-side.

Any help/ pointers would be massively appreciated!

Hey, you could do this with metadata and triggers. You could do a workflow, where you define metadata, and a trigger that automatically based on that metadata adds a role/whatever you need to define. Or you could do a Postgres function. If you feel stuck, I do 1:1 sessions where I do this kind of setups with people.

Thanks! the editors in maintenance right now, but give this route a try

will keep the 1:1 in mind for future

1 Like

Heads up for anyone that comes across the same challenge - Broberto’s suggestion worked

1 Like

Which way did you end up picking? PG procedures or metadata?

Metadata carrying a defined user_role variable in weweb. Then a trigger/function in supabase to insert a new record into a Roles table when a new user is added to the auth.user table

1 Like