Replies: 9 comments 23 replies
-
Use
But I found this way on discord , you need to modify the trigger function that handles the insert on your profile table (see documentation about how to create the trigger funnction). similar to this:
|
Beta Was this translation helpful? Give feedback.
-
Small addition to the solutionAs @ichbinedgar mentioned, the best solution approach is probably to use functions and triggers. However, for me, and other people in the comments, an error 500 has occurred again and again. When trying to fix my code, I noticed two issues:
After fixing these two issues, everything works fine for me. However, I think that the supabase documentation could be expanded a bit at this point, since I also had to spend a long time troubleshooting. |
Beta Was this translation helpful? Give feedback.
-
This is the solution that I found working in Feb, 2022 -
Make sure you add 'options' before 'data' for the For anyone looking to check if the user has already signed in, this is a working code in React
|
Beta Was this translation helpful? Give feedback.
-
Wonderful solution, but I want to create two types of user on two separate tables, for example public.profile and public.profile_2 with different data. Triggering a function isn't any use because this will only put the data onto a single databsase. |
Beta Was this translation helpful? Give feedback.
-
I thought of using metadata, the two types of user coudl be signalled in metadata so that the function could choose between them, but metadata is limited to 16KB per user so I can't put much data there to insert into each table |
Beta Was this translation helpful? Give feedback.
-
While you can just add metadata during sign up as stated in the docs:
And then access this metadata later:
You may want to use the approach outlined by @brendanfurtado due to the ease around subsequently editing the profiles table. In this case, you would not need to edit the auth.users metadata. |
Beta Was this translation helpful? Give feedback.
-
I have migrated to the new version of api, the version 2, and there currently is no way to access the usernames of my users, is anyone able to help? previously I was getting it through the signing method,in the new version it is not possible to do so |
Beta Was this translation helpful? Give feedback.
-
thanks to @brendanfurtado for a clear solution. I made a trigger before inserting into auth.users
and for triggering :
|
Beta Was this translation helpful? Give feedback.
-
Hi!
I want to create a userflow where user fill the signup form that contains 3 inputs: username, email, password, then at submit it should insert a new row in the
profiles
table with his/her username.I've followed the documentation on triggering a function that insert a row with the new id, which works well, but I don't know how to insert the username from the input as well.
I tried to do something like this:
In theory this should works well but I want to keep the
profiles
table secure so I added some policy to this table like(role() = 'authenticated':: text)
for INSERT and UPDATE. But that does not make any sense because at that point the user is not logged in 🙀What are the best practices for this functionnality which guarentee a secured profiles table? Should I add another policy instead of checking if user is authenticated?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions