UserSchema.methods.toJSON = function () { var user = this; var userObject = user.toObject();
return _.pick(userObject, ['_id', 'email']); };
UserSchema.methods.generateAuthToken = function () { var user = this; var access = 'auth'; var token = jwt.sign({_id: user._id.toHexString(), access}, 'abc123').toString();