schwarzsky
05/24/2022, 3:40 PMUser Management Starter
but in public.profiles
table: supabase does not save the user.user_metadata.username
, it saves e-mail for username. Any idea how to solve it?Needle
05/24/2022, 3:40 PMNeedle
05/24/2022, 3:40 PMgaryaustin
05/24/2022, 3:48 PMNeedle
05/24/2022, 3:48 PMschwarzsky
05/24/2022, 4:04 PMjs
const { error, data } = await supabase.auth.signUp({
email: email,
password: password
}, {
data: {
username: username
}
})
, just registering user with supabase auth, "user management starter" is in SQL Editor.schwarzsky
05/24/2022, 4:04 PM-- Create a table for Public Profiles
create table profiles (
id uuid references auth.users not null,
updated_at timestamp with time zone,
username text unique,
avatar_url text,
website text,
primary key (id),
unique(username),
constraint username_length check (char_length(username) >= 3)
);
alter table profiles
enable row level security;
create policy "Public profiles are viewable by everyone." on profiles
for select using (true);
create policy "Users can insert their own profile." on profiles
for insert with check (auth.uid() = id);
create policy "Users can update own profile." on profiles
for update using (auth.uid() = id);
-- Set up Realtime!
begin;
drop publication if exists supabase_realtime;
create publication supabase_realtime;
commit;
alter publication supabase_realtime
add table profiles;
-- Set up Storage!
insert into storage.buckets (id, name)
values ('avatars', 'avatars');
create policy "Avatar images are publicly accessible." on storage.objects
for select using (bucket_id = 'avatars');
create policy "Anyone can upload an avatar." on storage.objects
for insert with check (bucket_id = 'avatars');
create policy "Anyone can update an avatar." on storage.objects
for update with check (bucket_id = 'avatars');
garyaustin
05/24/2022, 4:09 PMschwarzsky
05/24/2022, 4:14 PM