Sign up with additional user metadata
Heyy, I am working on my project, and it's on Remix (nice react framework). I use supabase for authentication and supabase provides a nice way to signup up users using the email and the password, and there is also another field called "data".
I have a second table called Profiles and whenever a new user signs up, a function is called that will put that info into the new Table, where I can also add custom fields, as opposed to the default Users table provided by supabase.
My question is, how do I actually reference the data in the data field, with postgresql queries?
I haven't found a way to reference it.
Function that runs when a new user joins:
drop trigger if exists on_auth_user_created on auth.user;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
const { user, session, error } = await supabase.auth.signUp(
{
email: 'example@email.com',
password: 'example-password',
},
{
data: {
first_name: 'John',
age: 27,
},
}
)
```
I have a second table called Profiles and whenever a new user signs up, a function is called that will put that info into the new Table, where I can also add custom fields, as opposed to the default Users table provided by supabase.
My question is, how do I actually reference the data in the data field, with postgresql queries?
I haven't found a way to reference it.
Function that runs when a new user joins:
- I want to insert into public.profiles, the info that I receive in the data field sent with the example signup call that I have provided below the sql query.
```
create or replace function public.handle_new_user()
returns trigger
language plpgsql
security definer set search_path = public
as $$
begin
insert into public.profiles (id, email)
values (new.id, new.email);
return new;
end;
$$;
drop trigger if exists on_auth_user_created on auth.user;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
const { user, session, error } = await supabase.auth.signUp(
{
email: 'example@email.com',
password: 'example-password',
},
{
data: {
first_name: 'John',
age: 27,
},
}
)
```