#Convex auth change email as username

4 messages · Page 1 of 1 (latest)

mint swan
#

Is it possible to change the id from email to username in convex auth?

rotund hawkBOT
#

Hi @mint swan. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, it is possible to use a username as the unique identifier (id) instead of an email in Convex Auth, but it requires customization. By default, the built-in Password provider expects an email as the id. To use a username, you need to implement a custom authentication provider using the ConvexCredentials provider, which allows you to fully control the sign-in process and define what field is used as the unique account id.

You can use the ConvexCredentials provider and set up your own logic for account creation and authentication, specifying the username as the unique id. The Password provider is built on top of ConvexCredentials, so you can refer to its implementation as a starting point and adapt it for usernames instead of emails. This approach is mentioned in support threads and documentation:

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.
how can I implement username/email and password auth?

For more details on customizing the sign-in process, see the documentation on ConvexCredentials and the Password provider source for reference on how to structure your custom logic:
Completely customize the sign-in process

#

In summary: Yes, you can use a username as the id, but you need to implement a custom provider using ConvexCredentials and handle the logic for authentication and uniqueness yourself.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: