Hi All,
I am trying to connect own mysql server using CUSTOM MySql Database.
I have added following script in login Database Action Scripts.
function login(email, password, callback) {
var connectionConfiguration = {
host: '35.154.162.95',
user: 'test',
password: 'LUws4tVNP0s9m2mJ',
database: 'test'
};
var connection = mysql(connectionConfiguration);
connection.connect(function(err) {
if (err) {
console.log(connectionConfiguration);
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
var query = "SELECT * FROM users WHERE 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];
bcrypt.compare(password, user.password, function (err, isValid) {
if (err) {
callback(err);
} else if (!isValid) {
callback(new WrongUsernameOrPasswordError(email));
} else {
callback(null, {
id: user.id.toString(),
nickname: user.nickname,
email: user.email
});
}
});
});
}
But it is showing the error of 401 - Unauthorized .
Please help me out.