Replies: 6 comments 5 replies
-
I have this exact same issue. Can we please get an update on this. |
Beta Was this translation helpful? Give feedback.
-
I think you can get around this by using the supabase client in the browser to create the user and then when you get the user object back using the supbase client in the server with the server key to add the profile. You can also turn the email verification off and do it all in the browser. |
Beta Was this translation helpful? Give feedback.
-
You may need to reference |
Beta Was this translation helpful? Give feedback.
-
The recommended approach is to use a trigger to automatically insert into the With this, you wouldn't have to manually insert it and worry about having the right policies etc. The user's name can then be updated in the profiles table by having an update policy like |
Beta Was this translation helpful? Give feedback.
-
Probably not the answer you’re looking for, but I find that short signup forms are better converting anyway. You could get their email, wait for the confirmation, and then ask for name and other personal details as a first onboarding step (if that works for your product). |
Beta Was this translation helpful? Give feedback.
-
You add the first and last name to the user metadata and then insert that in the profiles table via a trigger: -- This trigger automatically creates a user and profile entry
-- when a new user signs up via Supabase Auth.
create function public.handle_new_user () returns trigger as $$ begin
insert into public.profiles (id, first_name, last_name)
values (
new.id,
new.raw_user_meta_data->>'first_name',
new.raw_user_meta_data->>'last_name'
);
return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users for each row
execute procedure public.handle_new_user (); |
Beta Was this translation helpful? Give feedback.
-
Hi all,
We are using Supabase for our user management. Our users authenticate with email+password.
We want the users to be able to also include a first and last name on the same sign up form.
After reading existing issues / recommendations / docs ( #1469, Managing User Data, Quickstart: React, Row Level Security, Auth, #2495 ) we built a 'profiles' table that stores any additional user data to their id and email. We have row level security enabled and we allow only logged in users to update the table. The issue we are facing is with the insert action.
Issue => since the user is not verified at the time of sign up (they will need to go to their email and click on the link for that), they aren't actually logged in after completing the sign up. This means that we need a policy allowing inserts to the 'profiles' table to be made only by users with a user id that exists in the 'users' table (the auth.users table). So the user id will be returned when we sign the user up for the first time, and that id will then be used for the check on the row policy for the insert.
Unfortunately, the policy doesn't seem to have the privilege to select all ids from the 'users' table. Can that be fixed? We are doing something wrong? Should I raise a bug or is this intentional?
The policy ->
CREATE POLICY "New profile can be added if the added user is registered." ON public.profiles WITH CHECK ( ( user_id IN ( SELECT users.id FROM users ) ) );
The error ->
ERROR: permission denied for table users
Help will be greatly appreciated because we are now forced to omit the full name from our sign up form and that creates a wave of changes in our UX flow designs.
Thank you so much!
Beta Was this translation helpful? Give feedback.
All reactions