diff --git a/src/controllers/accounts.js b/src/controllers/accounts.js index 781e3fdb02..c3be0c6aae 100644 --- a/src/controllers/accounts.js +++ b/src/controllers/accounts.js @@ -136,11 +136,18 @@ function getUserDataByUserSlug(userslug, callerUID, callback) { accountsController.getUserByUID = function(req, res, next) { var uid = req.params.uid ? req.params.uid : 0; - user.getUserData(uid, function(err, userData) { + async.parallel({ + settings: async.apply(user.getSettings, uid), + userData: async.apply(user.getUserData, uid) + }, function(err, results) { if (err) { return next(err); } - res.json(userData); + + results.userData.email = results.settings.showemail ? results.userData.email : undefined; + results.userData.fullname = results.settings.showfullname ? results.userData.fullname : undefined; + + res.json(results.userData); }); }; diff --git a/src/user.js b/src/user.js index 5b242bbcb0..0a7bd11196 100644 --- a/src/user.js +++ b/src/user.js @@ -104,7 +104,7 @@ var async = require('async'), } if (user.password) { - user.password = null; + user.password = undefined; } if (!parseInt(user.uid, 10)) {