/**
 * isAuthenticated
 * @description :: Policy that inject user in `req` via JSON Web Token
 */

var passport = require('passport');

module.exports = function (req, res, next) {
  passport.authenticate('jwt', function (error, user, info) {
    if (error) return res.serverError(error);
    if (!user) return res.unauthorized(null, info && info.code, info && info.message);

    req.user = user;

    next();
  })(req, res);
};

/**
 * isAuthenticated
 * @description :: Policy that inject user in `req` via JSON Web Token
 */

var _ = require('lodash');
var passport = require('passport');

module.exports = function (req, res, next) {
  passport.authenticate('jwt', function (error, user, info) {
    if (error || !user) return res.negotiate(_.assign(error || {}, info));

    req.user = user;

    next();
  })(req, res);
};

Fix policy for new responses
Fix policy for new responses
