Created
April 24, 2017 06:49
-
-
Save abhisek/b0e48edd3b3b43f3b90b5545249c8d07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jwt = require('express-jwt'); | |
var JwtTokenValidator = { | |
validateToken: function(req, res, next) { | |
if(req.user) { | |
next(); | |
} else { | |
res.status(401).json({ error: 'JwtMissingOrIncorrect', message: 'JWT token is missing or incorrect.' }); | |
} | |
} | |
} | |
app.use(jwt({ secret: process.env.AUTH0_CLIENT_SECRET, iss: process.env.AUTH0_ISS }), | |
function(req, res, next) { | |
JwtTokenValidator.validateToken(req, res, next); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment