johnoliver2342
01/13/2023, 6:48 AMrp_st
01/13/2023, 6:49 AMrp_st
01/13/2023, 6:49 AMrp_st
01/13/2023, 6:50 AMjohnoliver2342
01/13/2023, 6:50 AMrp_st
01/13/2023, 6:51 AMjohnoliver2342
01/13/2023, 7:31 AMrp_st
01/13/2023, 8:07 AMjohnoliver2342
01/13/2023, 8:32 AMoverride: {
apis: (originalImplementation: any) => {
return {
...originalImplementation,
emailPasswordEmailExistsGET: async function (input) {
input.options.res.sendJSONResponse({
message: 'my custom response',
});
return {
status: 'OK',
exists: false,
};
},
emailPasswordSignUpPOST: async function (input: any) {
if (
originalImplementation.emailPasswordSignUpPOST === undefined
) {
throw Error('Should never come here');
}
const formFields: any = input.formFields;
const inputObject: any = {};
for (let index = 0; index < formFields.length; index++) {
const element = formFields[index];
inputObject[element.id] = element.value;
}
const { email, firstName, lastName, phoneNumber } =
inputObject;
// First we call the original implementation of signUpPOST.
const response: any =
await originalImplementation.emailPasswordSignUpPOST(input);
response['user'] = {
...response['user'],
email,
firstName,
lastName,
phoneNumber,
};
console.log(response);
return response;
},
I have tried this but this is not working for me.rp_st
01/13/2023, 8:33 AMrp_st
01/13/2023, 8:34 AMinput.options.res.setStatusCode(200); // or any other status code
input.options.res.sendJSONResponse({
message: "my custom response",
//...
})
johnoliver2342
01/15/2023, 4:03 PMemailPasswordEmailExistsGET: async function (input) {
input.options.res.setStatusCode(200);
input.options.res.sendJSONResponse({
message: 'my custom response',
});
return {
status: 'OK',
exists: false,
};
},
This is not working. I am still getting the id that is generated by supertoken, timeJoined and email only.rp_st
01/15/2023, 6:06 PMrp_st
01/15/2023, 6:06 PMjohnoliver2342
01/16/2023, 4:26 AMjohnoliver2342
01/16/2023, 4:30 AM{
"status": "OK",
"user": {
"email": "mitulkheni695@gmail.com",
"id": "37ffadc9-3002-48g4-95bc-5230a44c5b47",
"timeJoined": 1673798066293
}
}
look at the id now, It is generated by supertoken library. I have another method in my nest app that saves the user data on signup/signin method in the postgres database. I want to get that id that is auto generated (primary key like 1,2,3 etc) in the responsejohnoliver2342
01/16/2023, 4:35 AMsupertokens.init({
appInfo: this.config.appInfo,
supertokens: {
connectionURI: this.config.connectionURI,
apiKey: this.config.apiKey,
},
recipeList: [
ThirdPartyEmailPassword.init({
providers: [
ThirdPartyEmailPassword.Google({
clientSecret: 'TODO: GOOGLE_CLIENT_SECRET',
clientId
}),
],
signUpFeature: {
formFields: [
{
id: 'firstName',
},
{
id: 'lastName',
},
{
id: 'phoneNumber',
},
],
},
override: {
apis: (originalImplementation: any) => {
return {
...originalImplementation,
emailPasswordSignUpPOST: async function (input: any) {
if (
originalImplementation.emailPasswordSignUpPOST === undefined
) {
throw Error
}
// retrieving data from input and saving logic goes here...
},
emailPasswordEmailExistsGET: async function (input) {
input.options.res.setStatusCode(200);
input.options.res.sendJSONResponse({
message: 'my custom response',
});
return {
status: 'OK',
exists: false,
};
},
};
},
},
}),
],
});
johnoliver2342
01/16/2023, 4:50 AMrp_st
01/16/2023, 5:27 AMjohnoliver2342
01/16/2023, 5:29 AMrp_st
01/16/2023, 5:29 AMjohnoliver2342
01/16/2023, 5:30 AMrp_st
01/16/2023, 5:31 AMjohnoliver2342
01/16/2023, 5:32 AMjohnoliver2342
01/16/2023, 5:33 AMrp_st
01/16/2023, 5:36 AMrp_st
01/16/2023, 5:36 AMjohnoliver2342
01/16/2023, 5:39 AMjscyo
01/16/2023, 5:48 AMSuperTokens.createUserIdMapping({ superTokensUserId: "SUPERTOKENS_USER_ID", externalUserId: "POSTGRES_USER_ID"});
to the signUp override code.johnoliver2342
01/16/2023, 5:52 AMjscyo
01/16/2023, 5:59 AMemailPasswordSignUpPOST:
override and pass the auto-generated postgres userId and SuperTokens userId to it, SuperTokens will now use the postgres userId for the user. So all subsequent signIn requests or function calls will return the postgres userId.johnoliver2342
01/16/2023, 6:01 AMjohnoliver2342
01/16/2023, 6:14 AMjscyo
01/16/2023, 6:16 AMjohnoliver2342
01/16/2023, 6:20 AMjscyo
01/16/2023, 6:26 AMjohnoliver2342
01/16/2023, 7:14 AMrp_st
01/16/2023, 7:18 AMjohnoliver2342
01/16/2023, 7:21 AMrp_st
01/16/2023, 7:22 AMrp_st
01/16/2023, 7:25 AMlancekey
01/17/2023, 5:22 PMlancekey
01/17/2023, 5:22 PMrp_st
01/17/2023, 6:06 PMrp_st
01/17/2023, 6:06 PMlancekey
01/17/2023, 6:45 PM