mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 08:31:22 +01:00
closes #6258
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
11
src/upgrades/1.8.0/give_signature_privileges.js
Normal file
11
src/upgrades/1.8.0/give_signature_privileges.js
Normal file
@@ -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);
|
||||
},
|
||||
};
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user