Hash phone number sent to authbox and don't crash w no authbox config
This commit is contained in:
parent
26104246ec
commit
5ca3eff6c2
@ -8,10 +8,10 @@
|
|||||||
"express": "~3.5.1"
|
"express": "~3.5.1"
|
||||||
, "authbox": "^0.9.2"
|
, "authbox": "^0.9.2"
|
||||||
, "jade": "~0.14.2"
|
, "jade": "~0.14.2"
|
||||||
|
, "mixpanel": "~0.0.19"
|
||||||
, "nodemailer": "~0.6.1"
|
, "nodemailer": "~0.6.1"
|
||||||
, "redis-url": "~0.2.0"
|
, "redis-url": "~0.2.0"
|
||||||
, "underscore": "~1.6.0"
|
, "underscore": "~1.6.0"
|
||||||
, "mixpanel": "~0.0.19"
|
|
||||||
}
|
}
|
||||||
, "devDependencies": {
|
, "devDependencies": {
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,23 @@
|
|||||||
var express = require('express')
|
var express = require('express')
|
||||||
, app = express()
|
, app = express()
|
||||||
, authbox = require('authbox')
|
|
||||||
, _ = require('underscore')
|
, _ = require('underscore')
|
||||||
|
, authbox = require('authbox')
|
||||||
|
, crypto = require('crypto')
|
||||||
|
, exec = require('child_process').exec
|
||||||
, fs = require('fs')
|
, fs = require('fs')
|
||||||
, mixpanel = require('mixpanel')
|
, mixpanel = require('mixpanel')
|
||||||
, exec = require('child_process').exec
|
|
||||||
, spawn = require('child_process').spawn
|
|
||||||
, Stream = require('stream')
|
|
||||||
, redis = require('redis-url').connect()
|
, redis = require('redis-url').connect()
|
||||||
|
, spawn = require('child_process').spawn
|
||||||
, text = require('../lib/text');
|
, text = require('../lib/text');
|
||||||
|
|
||||||
|
// Express config
|
||||||
|
app.set('views', __dirname + '/views');
|
||||||
|
app.set('view engine', 'jade');
|
||||||
|
|
||||||
|
app.use(express.cookieParser());
|
||||||
|
app.use(express.static(__dirname + '/public'));
|
||||||
|
app.use(express.bodyParser());
|
||||||
|
|
||||||
// Enable log messages when sending texts.
|
// Enable log messages when sending texts.
|
||||||
text.debug(true);
|
text.debug(true);
|
||||||
|
|
||||||
@ -34,6 +42,7 @@ try {
|
|||||||
try {
|
try {
|
||||||
authbox_config = require('./authbox_config.js');
|
authbox_config = require('./authbox_config.js');
|
||||||
authbox.configure(authbox_config);
|
authbox.configure(authbox_config);
|
||||||
|
app.use(authbox.middleware);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
authbox = {log: function() {}};
|
authbox = {log: function() {}};
|
||||||
}
|
}
|
||||||
@ -48,15 +57,6 @@ try {
|
|||||||
access_keys = {};
|
access_keys = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Express config
|
|
||||||
app.set('views', __dirname + '/views');
|
|
||||||
app.set('view engine', 'jade');
|
|
||||||
|
|
||||||
app.use(express.cookieParser());
|
|
||||||
app.use(express.static(__dirname + '/public'));
|
|
||||||
app.use(authbox.middleware);
|
|
||||||
app.use(express.bodyParser());
|
|
||||||
|
|
||||||
// App routes
|
// App routes
|
||||||
app.get('/', function(req, res) {
|
app.get('/', function(req, res) {
|
||||||
fs.readFile(__dirname + '/views/index.html', 'utf8', function(err, text){
|
fs.readFile(__dirname + '/views/index.html', 'utf8', function(err, text){
|
||||||
@ -103,12 +103,14 @@ function textRequestHandler(req, res, number, region, key) {
|
|||||||
var message = req.body.message;
|
var message = req.body.message;
|
||||||
if (message.indexOf(':') > -1) {
|
if (message.indexOf(':') > -1) {
|
||||||
// Handle problem with vtext where message would not get sent properly if it
|
// Handle problem with vtext where message would not get sent properly if it
|
||||||
// contains a colon
|
// contains a colon.
|
||||||
message = ' ' + message;
|
message = ' ' + message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shasum.update(number);
|
||||||
|
var authbox_digest = shasum.digest('hex');
|
||||||
_.extend(authbox_details, {
|
_.extend(authbox_details, {
|
||||||
recipient__phone: number,
|
recipient: number,
|
||||||
message__text: message
|
message__text: message
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user