John Oliver
01/13/2023, 6:48 AMrp
01/13/2023, 6:49 AMJohn Oliver
01/13/2023, 6:50 AMrp
01/13/2023, 6:51 AMJohn Oliver
01/13/2023, 7:31 AMrp
01/13/2023, 8:07 AMJohn Oliver
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
01/13/2023, 8:33 AMinput.options.res.setStatusCode(200); // or any other status code
input.options.res.sendJSONResponse({
message: "my custom response",
//...
})
John Oliver
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
01/15/2023, 6:06 PMJohn Oliver
01/16/2023, 4:26 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 responsesupertokens.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,
};
},
};
},
},
}),
],
});
rp
01/16/2023, 5:27 AMJohn Oliver
01/16/2023, 5:29 AMrp
01/16/2023, 5:29 AMJohn Oliver
01/16/2023, 5:30 AMrp
01/16/2023, 5:31 AMJohn Oliver
01/16/2023, 5:32 AMrp
01/16/2023, 5:36 AMJohn Oliver
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.John Oliver
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.John Oliver
01/16/2023, 6:01 AMjscyo
01/16/2023, 6:16 AMJohn Oliver
01/16/2023, 6:20 AMjscyo
01/16/2023, 6:26 AMJohn Oliver
01/16/2023, 7:14 AMrp
01/16/2023, 7:18 AMJohn Oliver
01/16/2023, 7:21 AMrp
01/16/2023, 7:22 AMlancekey
01/17/2023, 5:22 PMrp
01/17/2023, 6:06 PMlancekey
01/17/2023, 6:45 PM