I am following this guide for migrating users from a Wordpress database to Auth0
There is a recommended code snippet here to hit the Wordpress DB to check if the use exists before consuming a token. However, this link is dead and when I try and generate a callback, I get cryptic errors.
https://raw.githubusercontent.com/auth0/wp-auth0/4.4.0/lib/scripts-js/db-get-user.js
Anyone have suggestions what the code snippet should be? The following code returns an empty profile, which i’m fairly certain is because the URL endpoint isn’t configured correctly.
function getUser(email, callback) {
const request = require("request");
// Send user identifier to external database API
let options = {
url: configuration.endpointUrl,
body: {
email: email,
},
json: true, // Specify that the request and response should be JSON
};
request.post(options, (err, response, profileData) => {
// Return error in callback if there was an issue finding the user
if (err) {
return callback(
new Error("Could not determine if the user exists or not.")
);
} else {
// Return null in callback if the user was not found, return profile data in callback if the user was found
if (!profileData) {
return callback(null);
} else {
let profile = {
email: profileData.email,
};
return callback(null, profile);
}
}
});
}