Skip to content

Instantly share code, notes, and snippets.

@brigand
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brigand/cdfa6592e3cf2a2301d2 to your computer and use it in GitHub Desktop.
Save brigand/cdfa6592e3cf2a2301d2 to your computer and use it in GitHub Desktop.
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