Hi, I'm having issues to add a username. The entire override does not get called whenever I register...
u

[Manicraft1001]

about 3 years ago
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
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;