The engineers have come back saying that nothing is blocking the connection and if I deliberately misspell a column name I am alerted to the column name being incorrect
e.g. Invalid column name ‘mispelledColumnName’)
which suggests that I am in fact connecting.
If I connect live, I am told the username or password is incorrect even though they are correct.
When using the testing system I just get ‘401 - Unauthorized’
Is there anything else I could be missing? The script is the sqlServer template.
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: ‘correctusername’,
password: ‘correctpassword’,
server: ‘serverIPaddress’,
options: {
database: ‘correctDB’,
rowCollectionOnRequestCompletion: true
}
});
var query = "SELECT UserID, AdminContactFirstName, Username, Password " +
“FROM tbl_Users WHERE Username = @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][3].value, function (err, isValid) {
if (err) { callback(new Error(err)); }
else if (!isValid) { callback(new WrongUsernameOrPasswordError(email)); }
else {
callback(null, {
user_id: rows[0][0].value,
nickname: rows[0][1].value,
email: rows[0][2].value
});
}
});
}
});
request.addParameter('Email', sqlserver.Types.VarChar, email);
connection.execSql(request);
});
}