mehedi
mehedi4mo ago

how can I implement username/email and password auth?

I also want to allow users to enter username in email field while sign in or sign up
7 Replies
Convex Bot
Convex Bot4mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart4mo ago
Welcome! Are you using Clerk or Convex Auth, or something else? The easiest way to do auth in Convex is Clerk: https://docs.convex.dev/auth/clerk
mehedi
mehediOP4mo ago
@erquhart I am using convex auth
erquhart
erquhart4mo ago
I believe you would have to use the ConvexCredentials provider, which is barebones and requires you to provide your own authorize function. The Password provider implements ConvexCredentials, but in such a way that email is required. If I were trying to do username/password login, I would copy the Password provider and tweak it to work with usernames. Password Provider: https://github.com/erquhart/convex-auth/blob/e4a9e0e7de0da9160185ac0028cfb684a9bcd147/src/providers/Password.ts ConvexCredentials Provider: https://github.com/erquhart/convex-auth/blob/e4a9e0e7de0da9160185ac0028cfb684a9bcd147/src/providers/ConvexCredentials.ts cc/ @mikeysee I believe you've done this in the past, am I overcomplicating it?
mikeysee
mikeysee4mo ago
I havent done username / password before no, I have always done email / password. The issue with username / password is what happens if someone forgets their password? How are you going to get them their password reset link? You would be better doing email password for auth because you then always have their email as their way of proving their identity.
erquhart
erquhart4mo ago
Ah gotcha, there was another post from a while back where you mentioned it but you must have meant email.
mikeysee
mikeysee4mo ago
Ah okay, sorry my memory is just terrible!

Did you find this page helpful?