From 6ed979b1afe0326f71d3891a61314bb7c8693f78 Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Sun, 20 Apr 2014 12:07:48 +0300 Subject: [PATCH] simplified unpairing --- .jshintrc | 37 ++++--------------------------------- lib/app.js | 15 ++++++++++----- lib/routes.js | 6 ------ 3 files changed, 14 insertions(+), 44 deletions(-) diff --git a/.jshintrc b/.jshintrc index 78edf35a..0f4a7724 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,35 +1,6 @@ { - "white": false, + "trailing": false, "node": true, - "browser": true, - "esnext": true, - "bitwise": true, - "camelcase": true, - "curly": true, - "eqeqeq": true, - "immed": true, - "indent": 2, - "latedef": true, - "newcap": true, - "noarg": true, - "quotmark": "single", - "regexp": true, - "undef": true, - "unused": true, - "strict": true, - "trailing": true, - "smarttabs": true, - "globals": { - "angular": true, - "document": true, - "nf": true, - "$":true, - "_":true, - "Highcharts": true, - "timeseries": true, - "describe": true, - "beforeEach": true, - "afterEach": true, - "it": true - } -} + "unused": "last-param", + "globalstrict": true +} \ No newline at end of file diff --git a/lib/app.js b/lib/app.js index 95b375eb..ec73f61a 100644 --- a/lib/app.js +++ b/lib/app.js @@ -89,13 +89,18 @@ module.exports = function (options) { if (options.https) { authMiddleware = function(req, res, next) { var fingerprint = req.connection.getPeerCertificate().fingerprint; - var e = new Error('Unauthorized'); - e.status = 401; config.isAuthorized(fingerprint, function (err, device) { - if (err) { return next(e); } - if (!device) { return next(e); } - req.device = device; + if (err) { + var serverError = new Error('Internal Server Error'); + serverError.status = 500; + return next(serverError); + } + if (!device) { + var pairError = new Error('Not Found'); + pairError.status = 404; + return next(pairError); + } next(); }); }; diff --git a/lib/routes.js b/lib/routes.js index 3475a1d9..3ed539e8 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -18,12 +18,6 @@ Error.prototype.toJSON = function () { }; var poll = function(req, res) { - if (req.device.unpair) { - return res.json({ - unpair: true - }); - } - var rateRec = _trader.rate(req.params.currency); var satoshiBalanceRec = _trader.balance;