Hi, Sorry in advance if this has already been ask...
# support-questions-legacy
j
Hi, Sorry in advance if this has already been asked, I seached through the search engine but didn't find the information. I'd like to know if there is a way to sign in with an email or a custom username? The
/recipe/signin
API request parameters are only
email
and
password
but maybe there's a way to extend something and supports
email
or
username
parameters? Thanks in advance for your replies and suggestions 🙂
r
Hey
This is possible. You would need to give your own validation function on the frontend and backend that verifies the user input to allow email or username s
Checkout form field validators section in docs
j
Thanks for your reploy @rp_st ! I saw in the documentation that I can [add some extra fields with custom validation in the sign-up form](https://supertokens.com/docs/emailpassword/common-customizations/signup-form/adding-fields). I also saw that I can [change the
email
field label](https://supertokens.com/docs/emailpassword/common-customizations/signin-form/changing-field-labels), but I'm not sure that I can extend the backend sign-in process to handle authentication with email or username. What I'm looking for is that the user can fill the sign-in form with his email (e.g.
john.doe@gmail.com
) or his username (e.g.
john.doe
) and his password of course 🙂
r
So you can achieve that by changing the validator of the email on the frontend and backend to allow for an email or username
And then things should just work.
Of course, sending email verification emails or reset password emails will not work with a username. But you can override the APIs on the backend to return a nice error message in case the user has used a username
j
I think I see your point, the idea is to save an email or a username in the
email
property (with a custom validator) but it'll not offer a way for the member to sign in with his email or his username. What I'm looking for is to save both member's email and username and to handle this 2 information in the sign-in form. You mention that "you can override the APIs on the backend", do you have any documentation of this?
r
Ahh I see. So in the sign up form, you can add an extra field for the username. And during sign in, you can override the backend sign in api to detect if the input is a username, you fetch the email first, and then call the original implementation with the email and password
See the advanced customisation / override section -> backend APIs section in the docs
j
Wow it was exactly what I was looking for! Thanks a lot for your time and your help 😉