Hi, I'm having issues to add a username. The entir...
# support-questions
u
Hi, I'm having issues to add a username. The entire override does not get called whenever I register a new account. https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/signup-form/adding-fields
Copy code
typescript

const initSuperTokens = () => {
  supertokens.init({
    framework: "express",
    supertokens: {
      connectionURI: "REDACTED",
      apiKey: "REDACTED",
    },
    appInfo: {
      appName: "REDACTED",
      apiDomain: "http://localhost:3000",
      websiteDomain: "http://localhost:3000",
      apiBasePath: "/api/authentication",
      websiteBasePath: "/authentication",
    },
    recipeList: [
      ThirdPartyEmailPassword.init({
        override: {
          apis: (originalImplementation) => {
            return {
              ...originalImplementation,
              emailPasswordSignUpPOST: async function (input) {
                if (
                  originalImplementation.emailPasswordSignUpPOST === undefined
                ) {
                  throw Error("Should never come here");
                }

                // First we call the original implementation
                let response =
                  await originalImplementation.emailPasswordSignUpPOST(input);

                console.log("response");
                console.log(response);

                // If sign up was successful
                if (response.status === "OK") {
                  // We can get the form fields from the input like this
                  let formFields = input.formFields;
                  let user = response.user;

                  console.log(formFields);
                  console.log(user);
                  // TODO: register user in the database

                  // some post sign up logic
                }

                return response;
              },
            };
          },
        },
      }),
      Session.init(), // initializes session features
    ],
  });
};

export default initSuperTokens;
opened thread
p
This override is only called if you are signing up with email+password
You can also override
thirdPartySignInUpPOST
to handle social logins
u
I did sign up using email and password on the form. Must I override ``thirdPartySignInUpPOST`` because I'm using this specific recipe?
p
That's only called if the user signs in using a third party login method. If you are allowing both I think you should but strictly speaking you don't have to.
Also, you said you signed in using email and password, but the override is for sign up.
u
Sorry, I meant "sign up". If I want to use both third party and email + password, I must override both, correct?
p
yeah
still, it's very strange that this override didn't get called.
you are doing this on the backend side, right?
u
Yes, this is on the backend, not in the ``backendConfig`` or ``frontendConfig`` of the Next JS frontend.
I don't have the time rn to debug it further
I'll look into it asap
So I did some testing and everything seems to be at the right place. Sadly, I don't have a reprex (https://stackoverflow.com/help/minimal-reproducible-example) ready. However, I can send an archive that contains all supertokens relevant files, if that helps to identify the issue. If not, I can provide a reprex until friday evening. PS: please @ me
p
if you send the archive I'm happy to take look
u
Sure! Obviously, this won't compile. If we can't figure out the issue, I'll provide a reprex asap.
p
hmm, can you check if requests are routed to the ST instance configured in backend instead of the next authentication api path?
btw, why are there two separate backend configs?
u
It seems like, that the backend config (in ``backend/authentication``) does not get called. ST seems to access the api, as it should (as far as I know) Perhaps I need to move the override to the ``frontend/config/backendConfig.ts`` and remove ``backend/authentication``? For context: I need to verify both on my graphql api on the express backend and on the next ui ``/api``
p
well, the override config needs to be applied to the instance of supertokens that handles the signup request
I'd suggest using the same config for both instances
you could test which instance handles the signup request adding different overrides to each instance and you can see from the logs which gets called.
u
When I move the override from ``backend/authentication`` to ``frontend/config/backendConfig.ts`` it seems to work! (I see the user and the form input). But I still need the config in ``backend/authentication``, otherwise I can't verify the session on the graphql api easily, right?
I'll leave this thread now. ST is working and I should be able to implement the rest myself. Thank you 💪
p
oh, sorry, I didn't see the question at the end of the last message. So for session verification you only need the Session recipe configured, but yeah, in general both should be configured appropriately. If the graphql api never gets sign in/up calls, you don't really need those overrides there.