Tiger πŸ…
Tiger πŸ…β€’6mo ago

Questions about Convex Auth

- If I want to add a name field and customize the name of the user that gets authenticated, how do I do that? Is that via the createOrUpdateUser callback function? - If I want to provide email/password sign up but you still need to click the confirmation link upon signing up (not when logging in again with email/password) how do I implement this? I see that email/password seems quite straight forward (https://labs.convex.dev/auth/config/passwords#email--password-setup), but how can I implement a mechanism to say "isVerified" in the database for each user to determine whether they've verified their email upon signing up?
Passwords - Convex Auth
Relations, default values, unique fields and more for Convex
25 Replies
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
I'm gonna add my notes in here too redirect happens via redirectTo:
onClick={() => void signIn("apple", {
redirectTo: "/"
})}
onClick={() => void signIn("apple", {
redirectTo: "/"
})}
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
❓ Weird. Seems like redirect of callback should return an array of strings instead?
No description
Michal Srb
Michal Srbβ€’6mo ago
For adding name, which authentication methods do you want to use? Email verification for email+password is documented lower on the page you linked, and is all built-in. redirectTo is important because you might want to redirect to different dynamic URL determined at runtime.
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
- If user is authenticated, but not verified, how do I check that in the app? - I don't want to send OTP code.
Michal Srb
Michal Srbβ€’6mo ago
There’s emailVerificationTime field on the users table Do you want to send a magic link instead?
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
Should it not be different here? πŸ€” - One for signing in with password, getting authenticated, then the second one is the same?
No description
Michal Srb
Michal Srbβ€’6mo ago
Yeah; the arguments are different.
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
I think that would be the simpler approach, which we'll go with if we can't get this to work. but I was thinking - email/password approach - get verification email - when you come back to the app, email/password authentication
Michal Srb
Michal Srbβ€’6mo ago
The verification email has to be either magic link or otp Otherwise you don’t know the user owns the email address, right?
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
simpler because you can just do magic link every time the person auth if there, simply login if first time, create the user which i assume you handle for us although we still need to set the name in that case, i guess we can use the createOrUpdateUser callback function Yes, it would then be magic link indeed email/pass and ending it off with a magic link would we then do signin with "resend" as the second step
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
similar to this one
No description
Michal Srb
Michal Srbβ€’6mo ago
Ok, magic link is doable, the docs might cover it a bit, you need some routing and custom link so your app handles it correctly. I’d start with OTP and then swap for magic link later
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
Why is profile typed as any when configuring it in the google provider? I'm not getting the name in the profile inside the callback function
No description
No description
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
i want first and last name, compose that to create full name for user as name field on the user's doc
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
The docs cover it here https://labs.convex.dev/auth/config/email - if sign up, we'll create user with email/pass then send this email, is that possible? so first we do signIn("password") and then we do signIn("resend")
Magic Links - Convex Auth
Relations, default values, unique fields and more for Convex
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
that's how im thinking about it so if emailVerificationTime is there, it means verification is done, if undefined, it means not verified yet?
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
do i need to do this? πŸ€” get google profile and annotate it
No description
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
seems like it
No description
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
even for the apple one which is also different
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
as for knowing if some1 has verified i can use emailVerified i think and have a isUserVerified field on the user
No description
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
emailVerified is also a boolean, so yeah thatshould work when youve time @Michal Srb would appreciate if you could confirm some of the points above or if my understanding is incorrect ❀️
Michal Srb
Michal Srbβ€’6mo ago
OAuth: 1. You have to extract fields vis the profile method, then they’ll be available in createOrUpdateUser. If you don’t override createOrUpdareUser the result of profile() is automatically inserted into the users table. The builtin Password provider already supports immediate email verification. If requiring email verification on sign up is ok for you, I’d use that. No need to provide custom createOrUpdateUser.
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
No need to provide custom createOrUpdateUser.
im gonna have to see this in action, not sure but if i wanna check on the server or client whether user is email verified, how do i do that? so if i do the "resend" method how do i check if a user has verified their email also this will only happen on sign up to be clear 1. sign up 2. sign in with password 3. we call the resend method programmatically after the sign in method with password is through successfully
Michal Srb
Michal Srbβ€’6mo ago
Might be easier if you give it a try πŸ™‚
Tiger πŸ…
Tiger πŸ…OPβ€’6mo ago
Will do 😁❀️