From aa9fa224ed69ed0dd7de1cadd72c89dbc07fee60 Mon Sep 17 00:00:00 2001 From: Amir Date: Tue, 20 Jan 2015 15:43:57 +0100 Subject: [PATCH 1/2] Update jwtauth.js making app global so its accessible inside jwtauth --- lib/jwtauth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jwtauth.js b/lib/jwtauth.js index 35ddd12..5ccae0b 100644 --- a/lib/jwtauth.js +++ b/lib/jwtauth.js @@ -27,7 +27,7 @@ module.exports = function(req, res, next){ if (token) { try { - var decoded = jwt.decode(token, app.get('jwtTokenSecret')) + var decoded = jwt.decode(token, global.app.get('jwtTokenSecret')) if (decoded.exp <= Date.now()) { res.end('Access token has expired', 400) From 4dacc078344520b8e0ea7230b78276d48899c1d0 Mon Sep 17 00:00:00 2001 From: Amir Date: Tue, 20 Jan 2015 15:45:43 +0100 Subject: [PATCH 2/2] Update app.js --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index adc6e11..206aa2b 100644 --- a/app.js +++ b/app.js @@ -27,7 +27,7 @@ mongoose.connect('mongodb://localhost/jwttest'); * NOTE: purposely not using var so that app is accesible in modules. */ app = express() - +global.app = app; /** * Set the secret for encoding/decoding JWT tokens */