Merge pull request #35 from petehunt/better-ips

Send IP address to authbox
This commit is contained in:
Ian Webster 2015-01-03 19:23:25 -05:00
commit 4f22c477fa
2 changed files with 8 additions and 7 deletions

View File

@ -6,7 +6,7 @@
} }
, "dependencies": { , "dependencies": {
"express": "~3.5.1" "express": "~3.5.1"
, "authbox": "^0.9.2" , "authbox": "^0.9.3"
, "jade": "~0.14.2" , "jade": "~0.14.2"
, "mixpanel": "~0.0.19" , "mixpanel": "~0.0.19"
, "nodemailer": "~0.6.1" , "nodemailer": "~0.6.1"

View File

@ -89,8 +89,14 @@ app.post('/intl', function(req, res) {
// App helper functions // App helper functions
function textRequestHandler(req, res, number, region, key) { function textRequestHandler(req, res, number, region, key) {
var ip = req.connection.remoteAddress;
if (!ip || ip === '127.0.0.1') {
ip = req.header('X-Real-IP');
}
var authbox_details = { var authbox_details = {
$actionName: 'text' $actionName: 'text',
$ipAddress: ip
}; };
if (!number || !req.body.message) { if (!number || !req.body.message) {
@ -122,11 +128,6 @@ function textRequestHandler(req, res, number, region, key) {
return; return;
} }
var ip = req.connection.remoteAddress;
if (!ip || ip === '127.0.0.1') {
ip = req.header('X-Real-IP');
}
var tracking_details = { var tracking_details = {
number: number, number: number,
message: req.body.message, message: req.body.message,