From 719290cd2b8ba41fc17c35eb4cfbd68927e458c9 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 5 Nov 2014 23:58:46 -0500 Subject: [PATCH] dont display email/fullname if they are private --- src/controllers/accounts.js | 11 +++++++++-- src/user.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) 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)) {