Auth0 Home Blog Docs

Trying Get User and LOGIN Script It is Giving Profile Undefined

I have a custom database connection which is connected to MySQL database and when trying the get user and login script I am getting profile undefined I am attaching my get user script here and also the screenshot for my logs

Get User Script:

auth02

function getByEmail(email, callback) {
console.log("Executing Get User script...");
  const mysql = require('mysql@2.16.0');

  const connection = mysql.createConnection({
    host: configuration.DB_HOST,
    user: configuration.DB_USER,
    password: configuration.DB_PASSWORD,
    database: configuration.DB_NAME,
    ssl: {
       rejectUnauthorized: false,
     }
  });

console.log("Preparing connection to DB...");

  connection.connect();
console.log("Connected to DB: OK!");
  const query = 'SELECT user_id, email FROM users WHERE email = ?';

console.log("Query DB for email: " + email);
  connection.query(query, [ email ], function(err, results) {
console.log("Error???: " + err);
    if (err || results.length === 0) return callback(err || null);
console.log("Query executed OK!");
        console.log("Users found: " + results.length);
    if (results.length === 0) return callback();
    const user = results[0];

    callback(null, {
      user_id: user.user_id.toString(),
      email: user.email
    });
  });
}

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?