Ready to post? First, try searching for your answer.
I’m trying to set up a custom database to my Azure SQL Database with whitelist setting up (as attached image), but when I “Save and Try” the following script, just get the “Request to Webtask exceeded allowed execution time”. Also tried to check the log or Real-time Webtask logs, not much details from there. Could help me find a solution? Thanks!
function login(email, password, callback) {
//this example uses the "tedious" library
//more info here: http://pekim.github.io/tedious/index.html
const bcrypt = require('bcrypt');
const sqlserver = require('tedious@16.2.0');
const Connection = sqlserver.Connection;
const Request = sqlserver.Request;
const TYPES = sqlserver.TYPES;
const connection = new Connection({
userName: configuration.userName,
password: configuration.dbPassword,
server: configuration.DBServer,
options: {
database: configuration.dbName,
encrypt: true // for Windows Azure
}
});
const query = 'SELECT Id, UserName, Email, PasswordHash FROM dbo.AspNetUsers 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);
const request = new Request(query, function (err, rowCount, rows) {
if (err || rowCount < 1) return callback(err || new WrongUsernameOrPasswordError(email));
bcrypt.compare(password, rows[0][3].value, function (err, isValid) {
if (err || !isValid) return callback(err || new WrongUsernameOrPasswordError(email));
callback(null, {
user_id: rows[0][0].value,
nickname: rows[0][1].value,
email: rows[0][2].value
});
});
});
request.addParameter('Email', TYPES.VarChar, email);
connection.execSql(request);
});
}