v1.18.x
Baris Usakli 8 years ago
parent 949595fdf3
commit a9dbdc75af

@ -65,9 +65,9 @@
"nodebb-plugin-spam-be-gone": "0.5.0",
"nodebb-rewards-essentials": "0.0.9",
"nodebb-theme-lavender": "4.0.5",
"nodebb-theme-persona": "5.0.14",
"nodebb-theme-persona": "5.0.15",
"nodebb-theme-slick": "1.1.0",
"nodebb-theme-vanilla": "6.0.11",
"nodebb-theme-vanilla": "6.0.12",
"nodebb-widget-essentials": "3.0.1",
"nodemailer": "2.6.4",
"nodemailer-sendmail-transport": "1.0.0",

@ -13,7 +13,9 @@
"disable-email-changes": "Disable email changes",
"disable-password-changes": "Disable password changes",
"allow-account-deletion": "Allow account deletion",
"user-info-private": "Make user info private",
"user-info-private": "Hide user list and data from guests",
"hide-fullname": "Hide fullname from users",
"hide-email": "Hide email from users",
"themes": "Themes",
"disable-user-skins": "Prevent users from choosing a custom skin",
"account-protection": "Account Protection",

@ -85,13 +85,13 @@ helpers.getUserDataByUserSlug = function (userslug, callerUID, callback) {
userData.emailClass = 'hide';
if (!(isAdmin || isGlobalModerator || isSelf || (userData.email && userSettings.showemail))) {
if (!isAdmin && !isGlobalModerator && !isSelf && (!userSettings.showemail || parseInt(meta.config.hideEmail, 10) === 1)) {
userData.email = '';
} else if (!userSettings.showemail) {
userData.emailClass = '';
}
if (!isAdmin && !isGlobalModerator && !isSelf && !userSettings.showfullname) {
if (!isAdmin && !isGlobalModerator && !isSelf && (!userSettings.showfullname || parseInt(meta.config.hideFullname, 10) === 1)) {
userData.fullname = '';
}

@ -142,6 +142,9 @@ settingsController.get = function (req, res, callback) {
userData.allowUserHomePage = parseInt(meta.config.allowUserHomePage, 10) === 1;
userData.hideFullname = parseInt(meta.config.hideFullname, 10) === 1;
userData.hideEmail = parseInt(meta.config.hideEmail, 10) === 1;
userData.inTopicSearchAvailable = plugins.hasListeners('filter:topic.search');
userData.title = '[[pages:account/settings]]';

@ -91,8 +91,8 @@ userController.getUserDataByUID = function (callerUid, uid, callback) {
return callback(err || new Error('[[error:no-user]]'));
}
results.userData.email = results.settings.showemail ? results.userData.email : undefined;
results.userData.fullname = results.settings.showfullname ? results.userData.fullname : undefined;
results.userData.email = results.settings.showemail && parseInt(meta.config.hideEmail, 10) !== 1 ? results.userData.email : undefined;
results.userData.fullname = results.settings.showfullname && parseInt(meta.config.hideFullname, 10) !== 1 ? results.userData.fullname : undefined;
callback(null, results.userData);
});

@ -49,6 +49,9 @@ module.exports = function (Posts) {
userData.status = user.getStatus(userData);
userData.signature = validator.escape(String(userData.signature || ''));
userData.fullname = validator.escape(String(userData.fullname || ''));
if (parseInt(meta.config.hideFullname, 10) === 1) {
userData.fullname = undefined;
}
});
async.map(userData, function (userData, next) {

@ -7,6 +7,7 @@ var db = require('./database');
var posts = require('./posts');
var utils = require('./utils');
var plugins = require('./plugins');
var meta = require('./meta');
var user = require('./user');
var categories = require('./categories');
var privileges = require('./privileges');
@ -135,6 +136,12 @@ Topics.getTopicsByTids = function (tids, uid, callback) {
}, next);
},
function (results, next) {
if (parseInt(meta.config.hideFullname, 10) === 1) {
results.users.forEach(function (user) {
user.fullname = undefined;
});
}
var users = _.zipObject(uids, results.users);
var categories = _.zipObject(cids, results.categories);

@ -71,6 +71,18 @@
<span class="mdl-switch__label"><strong>[[admin/settings/user:user-info-private]]</strong></span>
</label>
</div>
<div class="checkbox">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" data-field="hideFullname">
<span class="mdl-switch__label"><strong>[[admin/settings/user:hide-fullname]]</strong></span>
</label>
</div>
<div class="checkbox">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" data-field="hideEmail">
<span class="mdl-switch__label"><strong>[[admin/settings/user:hide-email]]</strong></span>
</label>
</div>
</form>
</div>
</div>

@ -1532,4 +1532,54 @@ describe('User', function () {
});
});
});
describe('hideEmail/hideFullname', function () {
var uid;
after(function (done) {
meta.config.hideEmail = 0;
meta.config.hideFullname = 0;
done();
});
it('should hide email and fullname', function (done) {
meta.config.hideEmail = 1;
meta.config.hideFullname = 1;
User.create({
username: 'hiddenemail',
email: 'should@be.hidden',
fullname: 'baris soner usakli',
}, function (err, _uid) {
uid = _uid;
assert.ifError(err);
request(nconf.get('url') + '/api/user/hiddenemail', { json: true }, function (err, res, body) {
assert.ifError(err);
assert.equal(body.fullname, '');
assert.equal(body.email, '');
done();
});
});
});
it('should hide fullname in topic list and topic', function (done) {
Topics.post({
uid: uid,
title: 'Topic hidden',
content: 'lorem ipsum',
cid: testCid,
}, function (err) {
assert.ifError(err);
request(nconf.get('url') + '/api/recent', { json: true }, function (err, res, body) {
assert.ifError(err);
assert(!body.topics[0].user.hasOwnProperty('fullname'));
request(nconf.get('url') + '/api/topic/' + body.topics[0].slug, { json: true }, function (err, res, body) {
assert.ifError(err);
assert(!body.posts[0].user.hasOwnProperty('fullname'));
done();
});
});
});
});
});
});

Loading…
Cancel
Save