-
-
Save brigand/cdfa6592e3cf2a2301d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mysql = require('../lib/db'); | |
var pub = { | |
authorize:function(uid,origin, cb){ | |
mysql.getConnection(function(err, connection) { | |
if (err){ return cb(err); } | |
// Use the connection | |
connection.query('SELECT secret_key,domain_name FROM rs_eshop_auth WHERE secret_key = ?',uid, function(err, rows) { | |
if (err){ return cb(err); } | |
// And done with the connection. | |
connection.release(); | |
// Don't use the connection here, it has been returned to the pool. | |
if (rows[0].domain_name==origin) { | |
cb(null, true); | |
}else{ | |
cb(null, false); | |
} | |
}); | |
}); | |
} | |
}; | |
module.exports = pub; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment