Skip to content

Instantly share code, notes, and snippets.

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({
{
"userData": [
{
"email": "test@gmail.com",
"email_verified": true,
"identities": [
{
"user_id": "6093d157b1cc582332n379ef",
"provider": "auth0",
"connection": "Username-Password-Authentication",
@jscyo
jscyo / exportedAuth0DataHelper.js
Created November 18, 2021 10:46
Helper function for getting Auth0 users from exported data
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
@jscyo
jscyo / helper.js
Last active September 28, 2022 16:28
Helper functions for Auth0 to SuperTokens migration
let auth0Domain = "https://yourdomain.com"
let userIdMappingFile = "/userDataMapping.json"
let doesUserExistInAuth0DataBase = async (email, password) => {
let config = {
method: "post",
url: auth0Domain + "/oauth/token",
headers: {
@jscyo
jscyo / STConfig.js
Last active November 18, 2021 10:50
Init code
supertokens.init({
supertokens: {
connectionURI: stConnectionURI,
},
appInfo: {
appName: "SuperTokens Demo App",
apiDomain,
websiteDomain
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