Hello i'm trying to connect my MsSql database with my site wordpress site.
I got this script:
function login(email, password, callback) {
//this example uses the "tedious" library
//more info here: http://pekim.github.io/tedious/index.html
var connection = sqlserver.connect({
userName: 'xxx',
password: 'xxx',
server: 'xx.xx.xx.xx',
options: {
database: 'xxx',
port : 'xxx',
rowCollectionOnRequestCompletion: true
}
});
var query = "SELECT ID, FName, LName, email, password " +
"FROM dbo.Users WHERE email = @email";
connection.on('debug', function (text) {
console.log(text);
}).on('errorMessage', function (text) {
console.log(JSON.stringify(text, null, 2));
}).on('infoMessage', function (text) {
console.log(JSON.stringify(text, null, 2));
});
connection.on('connect', function (err) {
if (err) return callback(err);
var request = new sqlserver.Request(query, function (err, rowCount, rows) {
if (err) {
callback(new Error(err));
} else if (rowCount < 1) {
callback(new WrongUsernameOrPasswordError(email));
} else {
bcrypt.compare(password, rows[0][4].value, function (err, isValid) {
if (err) { callback(new Error(err)); }
else if (!isValid) { callback(new WrongUsernameOrPasswordError(email)); }
else {
callback(null, {
ID: rows[0][0].value,
FName: rows[0][1].value,
LName: rows[0][2].value,
email: rows[0][3].value
});
}
});
}
});
request.addParameter('email', sqlserver.Types.VarChar, email);
connection.execSql(request);
});
}
The problem is, my passwords in the database ARE not encrypted... but the script tries to compare by encrypting the password...
Can you help me solve this problem?
tnx
via Shurik Kravchenko
No comments:
Post a Comment