If you do not have a trigger/function set up, then...
# help
b
If you do not have a trigger/function set up, then the
public.users
table will not have a new line until you insert one. So the
uid
of the row in
auth.users
will match the foreign key of
user_id
in
public.users
. So they should be unique and not repeat. Once a user registers you can redirect them to say
/profiles
and from there query for their
session.user.id
in the
public.users
table and if it does not exist, this is a new user. Of course this is just one way and I am sure there are other, more effective ways.
j
aah yeah, got you. I got a trigger set up for inserting users in public.users after signup, so I guess this solution won't work for me, if I got your description correctly
b
if you want to keep your trigger, you could check against a field like
first_name
or
last_name
that does not get automatically field by the trigger
j
yeah, but then I'd have to rely on a UI that enable users to add first_name and last_name AND that the user actually fill in the form in the UI, otherwise this scenario would be true even the second time the user logs in :/
The use case I have is that I want to create a Stripe customer on signup, and collect the stripe_id I get from Stripe, and the user_id in a table. The stripe-part is easy, as they only require an email to create a customer. But the user_id from the user is not generated until the user confirms their email
I could create a explicit route in my app, that users only get redirected to after signup, but that feels kinda bad tbh.
b
could you just turn off the email confirmation setting?
j
No, I can't :/ I think I'll go with the explicit route for now, until I have a better option. Thanks for discussing with me!