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 */ 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)