Auth0 Home Blog Docs

Custom DB MySQL for WordPress. Login script is adding a new user instead of login in.



When I login to wordpress using the Auth0 Plugin and the Auth0 interface it creates a new user instead of login in with the provided email and password. I am using a Custom DB with MySQL. This is my script. Any ideas why? Thanks!

function login(email, password, callback) {
console.log("Executing Get User script...");
var connectionConfiguration = {
host: configuration.DB_HOST,
user: configuration.DB_USER,
password: configuration.DB_PASSWORD,
database: configuration.DB_NAME,
console.log("Preparing connection to DB...");
var mysql_b = require('mysql');
var connection = mysql_b.createConnection(connectionConfiguration);


var query = "SELECT id, user_email, user_pass, user_nicename " +
"FROM wp_users WHERE user_email = user_email";

connection.query(query, [email], function (err, results) {
if (err) return callback(err);
if (results.length === 0) return callback(new WrongUsernameOrPasswordError(email));
var user = results[0];

```, user.user_pass, function (err, isValid) {
  if (err) {
  } else if (!isValid) {
    callback(new WrongUsernameOrPasswordError(email));
  } else {
    callback(null, {
      nickname: user.user_nicename,
      email: user.user_email