utils/jwt.js
function generateForUser(user, existingToken) {
        existingToken = existingToken || {};

        var privateKey = config.security.token.privateKey;
        var decryptedToken = _.extend(existingToken, { _id: user._id, authToken: user.authToken });

        return jsonwebtoken.sign(decryptedToken, privateKey);
    }
function generateForUser(user, existingToken) {
        existingToken = existingToken || {};

        var privateKey = config.security.token.privateKey;
        var decryptedToken = _.extend(existingToken, { _id: user._id, authToken: user.authToken });

        return jsonwebtoken.sign(decryptedToken, privateKey);
    }
function generateForUser ( user , existingToken ) { existingToken = existingToken || { } ; var privateKey = config . security . token . privateKey ; var decryptedToken = _ . extend ( existingToken , { _id : user . _id , authToken : user . authToken } ) ; return jsonwebtoken . sign ( decryptedToken , privateKey ) ; }
Simple function to generate a JWT based off a user
@param user
@param existingToken Optional, pass in if there is an existing token we are adding to
@returns {*}
Simple function to generate a JWT based off a user