Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify set profile database trigger to get data from Google metadata #50

Open
Dosbodoke opened this issue Dec 2, 2024 · 1 comment
Open
Assignees

Comments

@Dosbodoke
Copy link
Owner

https://boardshape.com/engineering/how-to-pull-google-profile-through-on-account-creation-with-supabase

@Dosbodoke
Copy link
Owner Author

Possible solution

CREATE OR REPLACE FUNCTION public.handle_new_user()
 RETURNS trigger
 LANGUAGE plpgsql
 SECURITY DEFINER
 SET search_path TO 'public'
AS $function$
BEGIN
  INSERT INTO public.profiles (id, profile_picture)
  VALUES (new.id, (SELECT raw_user_meta_data ->> 'avatar_url' FROM auth.users WHERE id = new.id))
  ON CONFLICT (id) DO NOTHING; -- Prevents error if the profile already exists
  RETURN new;
END;
$function$;

@Dosbodoke Dosbodoke self-assigned this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant