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
ThirdPartyPasswordless.init({ | |
contactMethod: "EMAIL_OR_PHONE", | |
flowType: "USER_INPUT_CODE_AND_MAGIC_LINK", | |
override: { | |
functions: (oI) => { | |
return{ | |
...oI, | |
consumeCode: async (input) => { | |
// use listCodesByPreAuthSessionId to retrieve details about the current user | |
let codeResponse = await ThirdPartyPasswordless.listCodesByPreAuthSessionId({ |
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
{ | |
"userData": [ | |
{ | |
"email": "[email protected]", | |
"email_verified": true, | |
"identities": [ | |
{ | |
"user_id": "6093d157b1cc582332n379ef", | |
"provider": "auth0", | |
"connection": "Username-Password-Authentication", |
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
let getEmailPasswordUserIfExistInAuth0 = async (email, password) => { | |
try { | |
let auth0UsersDataString = fs.readFileSync(__dirname + auth0ExportedUsersDataFile) | |
let auth0UsersData = JSON.parse(auth0UsersDataString); | |
// get auth0 user info | |
let auth0UsersInfo = auth0UsersData.userData | |
// get auth0 password hashes | |
let auth0PasswordHashes = auth0UsersData.passwordHashes |
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
let auth0Domain = "https://yourdomain.com" | |
let userIdMappingFile = "/userDataMapping.json" | |
let doesUserExistInAuth0DataBase = async (email, password) => { | |
let config = { | |
method: "post", | |
url: auth0Domain + "/oauth/token", | |
headers: { |
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
supertokens.init({ | |
supertokens: { | |
connectionURI: stConnectionURI, | |
}, | |
appInfo: { | |
appName: "SuperTokens Demo App", | |
apiDomain, | |
websiteDomain |
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
function redeemToken(passwordResetToken, newPassword) { | |
/* | |
First we hash the token, and query the db based on the hashed value. If nothing is found, then we throw an error. | |
*/ | |
hashedToken = hash_sha256(passwordResetToken); | |
rowFromDb = db.getRowTheContains(hashedToken) | |
if (rowFromDb == null) { | |
throw Error("invalid password reset token") | |
} | |
userId = rowFromDb.user_id |