ty! i’m new to auth and triggers. let’s say i want...
# help
t
ty! i’m new to auth and triggers. let’s say i want to set a trigger where if a new github user signs up. it will update their profile with their github username and avatar_url. so the user doesn’t have to set it. ty for help.
j
will update their profile with their github username and avatar_url on signup
This might be worth looking at it. https://github.com/supabase/supabase/tree/master/examples/nextjs-slack-clone#postgres-row-level-security *scroll down to the part of the schema that says "-- inserts a row into public.users and assigns roles"* In our Slack clone example app, there is a trigger called
on_auth_user_created
that runs a function called
public.handle_new_user()
the trigger in the example is would pretty much be the same, as you need to just run a function whenever a new user is added to auth.users But you should be able to change the handle_new_user function to do whatever you like, make it check that it is a github signup, and if so, add the relevant username and avatar_url to a public table for you.
it might be that the user profile image and username are actually available in the auth.users table already.
I would need to ask around.. anyone reading this might know as well
also, this is some of the official docs for setting up a trigger for new users signing up. https://supabase.com/docs/guides/auth/managing-user-data#using-triggers
I also suspect that Supabase Auth tries to get the most recent profile image from the 0auth provider whenever a user signs in. Which would be handy since users on Google, Facebook etc might update their profile from time to time. @User might be able to confirm if that's the case, these been quite a few updates recently.