Hello <@498057949541826571> Is there any way i c...
# support-questions-legacy
p
Hello @rp_st Is there any way i can use text instead of email to sign in. I know i can create user with text instead of email.
r
Hey @porcx
When you say text, do you mean username?
p
yes
@rp_st yes i mean username.
r
Right. So can you describe the flow a bit? Does the user also have the email? Or just username? Will their sign in using email or username or just username?
p
No We are not allow to have any kind of information from user so we auto generate username and create user and provide them credentials. How ever when user tries to login it throws invalid email. @rp_st
r
Right yea. So you need to change the email validation function to allow any text
p
@rp_st yes. 🙂
r
If you can wait for a few days, we are currently writing a guide for this flow which you can see and copy / paste code from
p
anyother solution that you can provide for now so that we can proceed 🙂
@rp_st
r
Yea. Checkout twice for form field validators. It shows you how to change the email validation logic on the frontend and backend.
You will also need to disable the password reset flow APIs which you can see in the section about hooks and actions
Finally, disabling the password reset ui (in case you are using the pre built ui can be done via component override and css.
p
@rp_st what i got it this for signup
Copy code
EmailPassword.init({
            signInAndUpFeature: {
                signUpForm: {
                    formFields: [{
                        id: "name",
                        label: "Full name",
                        placeholder: "First name and last name"
                    }, {
                        id: "age",
                        label: "Your age",
                        placeholder: "How old are you?",
                        optional: true,

                        /* Validation method to make sure that age is above 18 */
                        validate: async (value) => {
                            if (parseInt(value) > 18) {
                                return undefined; // means that there is no error
                            }
                            return "You must be over 18 to register";
                        }

                    }, {
                        id: "country",
                        label: "Your country",
                        placeholder: "Where do you live?",
                        optional: true
                    }]
                }
            }
        }),
@rp_st and what i have is this
Copy code
input.formFields = formFields;

                const response = await originalImplementation.signInPOST(input);
Can i implement similar to signinpost as well ?
r
Not really. You need change the validate function in the formField for
id: email
to allow usersname
something like this
so this will allow the sign up API to take any string as an "email" effectively treating it as a username
you don't need to change anything in the sign in POST API.
you could also just wait for docs on this - it should be done by tomorrow evening
p
@rp_st i will test things out and see other wise will wait. Thanks 🙂
r
cool
hey @porcx
we have added docs for username and password customisations here: https://supertokens.com/docs/emailpassword/common-customizations/username-password/overview