Skip to content

Instantly share code, notes, and snippets.

@abhisek
Created April 24, 2017 06:49
Show Gist options
  • Save abhisek/b0e48edd3b3b43f3b90b5545249c8d07 to your computer and use it in GitHub Desktop.
Save abhisek/b0e48edd3b3b43f3b90b5545249c8d07 to your computer and use it in GitHub Desktop.
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