-
-
Save jscyo/8a26e4324b6943e1b240fa5259554437 to your computer and use it in GitHub Desktop.
Map External UserId on successfull signup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SuperTokens from "supertokens-node"; | |
import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword"; | |
ThirdPartyEmailPassword.init({ | |
override: { | |
functions: (oI) => { | |
return { | |
...oI, | |
emailPasswordSignUp: async function (input){ | |
let response = await oI.emailPasswordSignUp(input); | |
if(response.status === "OK"){ | |
// on successful signup | |
// retrieve/generate your postgres userId | |
let postgresUserId = "YOUR_POSTGRES_USER_ID" | |
await SuperTokens.createUserIdMapping({superTokensUserId: response.user.id, externalUserId: postgresUserId}); | |
// update the response to use the postgresUserId | |
response.user.id = postgresUserId | |
} | |
return response; | |
} | |
} | |
} | |
} | |
}) | |
mitulkheni
commented
Jan 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment