diff --git a/install/package.json b/install/package.json index d6441ffc07..d2739fe6ad 100644 --- a/install/package.json +++ b/install/package.json @@ -73,7 +73,7 @@ "nodebb-plugin-spam-be-gone": "0.5.3", "nodebb-rewards-essentials": "0.0.11", "nodebb-theme-lavender": "5.0.3", - "nodebb-theme-persona": "7.2.26", + "nodebb-theme-persona": "7.2.27", "nodebb-theme-slick": "1.1.4", "nodebb-theme-vanilla": "8.1.11", "nodebb-widget-essentials": "4.0.2", diff --git a/src/controllers/accounts/edit.js b/src/controllers/accounts/edit.js index 08f5edfaf3..3402c3052a 100644 --- a/src/controllers/accounts/edit.js +++ b/src/controllers/accounts/edit.js @@ -17,9 +17,17 @@ var editController = module.exports; editController.get = function (req, res, callback) { async.waterfall([ function (next) { - accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, next); + async.parallel({ + userData: function (next) { + accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, next); + }, + canUseSignature: function (next) { + privileges.global.can('signature', req.uid, next); + }, + }, next); }, - function (userData, next) { + function (results, next) { + var userData = results.userData; if (!userData) { return callback(); } @@ -30,7 +38,7 @@ editController.get = function (req, res, callback) { userData.allowAccountDelete = parseInt(meta.config.allowAccountDelete, 10) === 1; userData.allowWebsite = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:website'], 10) || 0); userData.allowAboutMe = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:aboutme'], 10) || 0); - userData.allowSignature = !userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:signature'], 10) || 0); + userData.allowSignature = results.canUseSignature && (!userData.isSelf || parseInt(userData.reputation, 10) >= (parseInt(meta.config['min:rep:signature'], 10) || 0)); userData.profileImageDimension = parseInt(meta.config.profileImageDimension, 10) || 200; userData.defaultAvatar = user.getDefaultAvatar(); diff --git a/src/install.js b/src/install.js index 33bd5a58d1..9113103c52 100644 --- a/src/install.js +++ b/src/install.js @@ -356,7 +356,7 @@ function createGlobalModeratorsGroup(next) { function giveGlobalPrivileges(next) { var privileges = require('./privileges'); - privileges.global.give(['chat', 'upload:post:image'], 'registered-users', next); + privileges.global.give(['chat', 'upload:post:image', 'signature'], 'registered-users', next); } function createCategories(next) { diff --git a/src/posts/user.js b/src/posts/user.js index 2ada0b2dd3..8fd1e08bb0 100644 --- a/src/posts/user.js +++ b/src/posts/user.js @@ -7,12 +7,14 @@ var user = require('../user'); var groups = require('../groups'); var meta = require('../meta'); var plugins = require('../plugins'); +var privileges = require('../privileges'); module.exports = function (Posts) { Posts.getUserInfoForPosts = function (uids, uid, callback) { var groupsMap = {}; var userData; var userSettings; + var canUseSignature; async.waterfall([ function (next) { async.parallel({ @@ -22,11 +24,15 @@ module.exports = function (Posts) { userSettings: function (next) { user.getMultipleUserSettings(uids, next); }, + canUseSignature: function (next) { + privileges.global.can('signature', uid, next); + }, }, next); }, function (results, next) { userData = results.userData; userSettings = results.userSettings; + canUseSignature = results.canUseSignature; var groupTitles = userData.map(function (userData) { return userData && userData.groupTitle; }).filter(function (groupTitle, index, array) { @@ -74,7 +80,7 @@ module.exports = function (Posts) { groups.isMember(userData.uid, userData.groupTitle, next); }, signature: function (next) { - if (!userData.signature || parseInt(meta.config.disableSignatures, 10) === 1) { + if (!userData.signature || !canUseSignature || parseInt(meta.config.disableSignatures, 10) === 1) { userData.signature = ''; return next(); } diff --git a/src/privileges/global.js b/src/privileges/global.js index f1f88c4fff..3f2955d5be 100644 --- a/src/privileges/global.js +++ b/src/privileges/global.js @@ -16,12 +16,14 @@ module.exports = function (privileges) { { name: 'Chat' }, { name: 'Upload Images' }, { name: 'Upload Files' }, + { name: 'Signature' }, ]; privileges.global.userPrivilegeList = [ 'chat', 'upload:post:image', 'upload:post:file', + 'signature', ]; privileges.global.groupPrivilegeList = privileges.global.userPrivilegeList.map(function (privilege) { diff --git a/src/upgrades/1.8.0/give_signature_privileges.js b/src/upgrades/1.8.0/give_signature_privileges.js new file mode 100644 index 0000000000..87d93605f5 --- /dev/null +++ b/src/upgrades/1.8.0/give_signature_privileges.js @@ -0,0 +1,11 @@ +'use strict'; + +var privileges = require('../../privileges'); + +module.exports = { + name: 'Give registered users signature privilege', + timestamp: Date.UTC(2018, 1, 28), + method: function (callback) { + privileges.global.give(['signature'], 'registered-users', callback); + }, +}; diff --git a/test/categories.js b/test/categories.js index 90198f91b4..d0d446942b 100644 --- a/test/categories.js +++ b/test/categories.js @@ -668,6 +668,7 @@ describe('Categories', function () { chat: false, 'upload:post:image': false, 'upload:post:file': false, + signature: false, }); done(); @@ -704,6 +705,7 @@ describe('Categories', function () { 'groups:chat': true, 'groups:upload:post:image': true, 'groups:upload:post:file': false, + 'groups:signature': true, }); done(); diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js index 0bef41c466..6553363dc4 100644 --- a/test/mocks/databasemock.js +++ b/test/mocks/databasemock.js @@ -202,7 +202,7 @@ function setupDefaultConfigs(meta, next) { function giveDefaultGlobalPrivileges(next) { var privileges = require('../../src/privileges'); - privileges.global.give(['chat', 'upload:post:image'], 'registered-users', next); + privileges.global.give(['chat', 'upload:post:image', 'signature'], 'registered-users', next); } function enableDefaultPlugins(callback) {