silentworks
10/03/2021, 6:42 PMsilentworks
10/03/2021, 6:44 PMsilentworks
10/03/2021, 6:51 PMauth.users
and then you could store that in the session, then when you call signUp, you pass this id along as a additional data and do an update on the table at that point to store the uuid from the auth.users
tablesilentworks
10/03/2021, 6:51 PMrealmike
10/03/2021, 6:53 PMsilentworks
10/03/2021, 6:54 PMrealmike
10/03/2021, 7:22 PMrealmike
10/03/2021, 7:22 PMsilentworks
10/03/2021, 8:06 PMrealmike
10/03/2021, 9:06 PMrealmike
10/03/2021, 9:09 PMsilentworks
10/03/2021, 9:11 PMauth.users
table, but this you could do in your own public.users
table, since this would be created by yourealmike
10/03/2021, 9:40 PMsilentworks
10/03/2021, 10:25 PMpublic.users
while having a separate foreign key in the same table for auth.users
realmike
10/04/2021, 12:29 AMsilentworks
10/04/2021, 10:05 AMpublic.users
is a table that you create yourself, so there are no defaultslightbulbly
02/21/2022, 8:51 PMcreate or replace function public.handle_new_user()
returns trigger as $$
begin
insert into public.users (id, email, first_name, last_name)
values (new.id, new.email, PlaceholderA?, PlaceholderB?);
return new;
end;
$$ language plpgsql security definer;
drop trigger if exists on_auth_user_created on auth.users;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
lightbulbly
02/21/2022, 8:53 PMlightbulbly
02/21/2022, 8:54 PM// Calls signUp function from the context
const { error } = await signUp(
{ email: email, password: password },
{
data: {
first_name: firstName,
last_name: lastName,
},
}
);
lightbulbly
02/21/2022, 9:00 PM-- USERS
DROP TABLE if exists public.users cascade;
create table public.users (
id uuid references auth.users not null,
email text,
first_name text,
last_name text,
primary key (id)
);
alter table public.users enable row level security;
silentworks
02/21/2022, 9:05 PMlightbulbly
02/21/2022, 9:06 PMlightbulbly
02/21/2022, 9:52 PMconst { user, error } = await signUp(
{ email, password },
{
data: {
first_name,
last_name,
},
}
);
lightbulbly
02/21/2022, 9:53 PMcreate or replace function public.handle_new_user()
returns trigger as $$
begin
insert into public.users (id, email, first_name, last_name)
values (new.id, new.email,new.raw_user_meta_data->>'first_name', new.raw_user_meta_data->>'last_name');
return new;
end;
$$ language plpgsql security definer;
drop trigger if exists on_auth_user_created on auth.users;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
lightbulbly
02/21/2022, 9:53 PMlightbulbly
02/21/2022, 9:55 PMsilentworks
02/21/2022, 9:56 PMlightbulbly
02/21/2022, 9:57 PM