mercredi 15 avril 2015

mysql user authentication for nodeftpd

I would like to use nodeftpd with mysql authentication, but the problem is connection.query() is async and script finishes before mysql returns results.


Although, I have worked out a solution already but it's a hack and not really a solution and is ugly. So how to use mysql to authenticate in the command:pass of the nodeftpd library


So its more of a how to asynch properly, probably!



conn.on('command:pass', function(pass, success, failure) {

if(pass)
con.query('select * from wp_users where user_login = ? and user_pass = ?',[username, pass], function(err, rows, fields){
if(rows.length > 0 ){
success();
return;
}else{
failure();
return;
}
console.log('yy');

});
console.log('xx');
failure();
});

Aucun commentaire:

Enregistrer un commentaire