Hello, I am trying to add extra fields to my email password recipe, I have extended the field form t...
b
Hello, I am trying to add extra fields to my email password recipe, I have extended the field form to accommodate the extras just like the documentation ,but I still get an error " message: Are you sending too many/too few formfields?"
r
hey @black_silver
have you added the extra form field on the frontend and backend?
b
Yh,
r
can i see the config please? on frontend and backend
b
recipeList: [ EmailPassword.init({ signUpFeature: { formFeilds: [{ id: "email" }, { id: "password" }, { id: "firstName", optional: true }, { id: "lastName", optional: true }, { id: "mobileContact", optional: true }] }, override: { apis: (originalImplementation) => { return { ...originalImplementation, signUpPOST: async function(input) { if (originalImplementation.signUpPOST === undefined) { throw Error("Should never come here"); } // First we call the original implementation of signUpPOST. let response = await originalImplementation.signUpPOST(input); if (response.status === "OK") { let { id, email } = response.user; let formFields = input.formFields; console.log({ formFields, id, email }); } return response } } } } }), // initializes signin / sign up features Session.init({}) // initializes session features ] });
the above is the backend config
recipeList: [ supertokensEmailPassword.init({ signInAndUpFeature: { signUpForm: { formFeilds: [{ id: "email" }, { id: "password" }, { id: "firstName" }, { id: "lastName" }, { id: "mobileContact" }] } } }), supertokensSession.init() ], });
r
you need to also specify the optional attribute in the backend
also, whats the APi call that you are making?
right now, putting something as optional is a bit misleading at the moment, as you still need to give it in the API input, but it can be an empty string vs non optional which must not be an empty string
b
i have already
r
try setting optional: true on both frontend and backend for the configs
i don't get this. Can you show me the network call that's being made? The request body
b
Copy code
{
  "formFields": [
    {
      "id": "email",
      "value": "courageagbenyegah@yahoo.com"
    },
    {
      "id": "password",
      "value": "6GZ8zYZ88S7LZiW"
    },
    {
      "id": "firstName",
      "value": "courage"
    },
    {
      "id": "lastName",
      "value": "kekeli"
    },
    {
      "id": "mobileContact",
      "value": "5788958"
    }
  ]
}
r
hmm. Seems about right
are you making the request via postman or something? Or via our frontend functions / pre built UI?
b
frontend function
r
can i see how?
b
Copy code
supertokensEmailPassword.init({
            signInAndUpFeature: {
                signUpForm: {
                    formFeilds: [{
                        id: "email"
                    }, {
                        id: "password"
                    }, {
                        id: "firstName",
                        optional: true
                    }, {
                        id: "lastName",
                        optional: true

                    }, {
                        id: "mobileContact",
                        optional: true
                    }]
                }
            }
        }),
        supertokensSession.init()
    ],
Copy code
let response = await supertokensEmailPassword.signUp({
        formFields: [{
                id: "email",
                value: await values.email
            },
            {
                id: "password",
                value: await values.password
            },
            {
                id: "firstName",
                value: await values.firstName
            },
            {
                id: "lastName",
                value: await values.otherNames
            },
            {
                id: "mobileContact",
                "value": await values.mobile
            }
        ]
    })
r
from the backend formFields, can you remove email and password items? cause that gets added on its own
and same thing for frontend
b
alright
r
so the form fields just contains firstName, lastName and mobileContact
email and password gets added implicitly
b
Copy code
signInAndUpFeature: {
                signUpForm: {
                    formFeilds: [{
                        id: "firstName",
                        optional: true
                    }, {
                        id: "lastName",
                        optional: true

                    }, {
                        id: "mobileContact",
                        optional: true
                    }]
                }
            }
current frontend config
Copy code
signUpFeature: {
                formFeilds: [{
                    id: "firstName",
                    optional: true
                }, {
                    id: "lastName",
                    optional: true

                }, {
                    id: "mobileContact",
                    optional: true

                }]
            }
current backend config
{"message":"Are you sending too many / too few formFields?"}
current responds
r
hmm. Thats really strange
can you open an issue about this on our github? We will investigate it
b
Weird thing is when I use the email and password for the sign-up form it works smoothly
Alright sure
r
thanks. We will check it out
255 Views