mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #6497
This commit is contained in:
@@ -17,6 +17,7 @@ module.exports = function (privileges) {
|
|||||||
{ name: 'Upload Images' },
|
{ name: 'Upload Images' },
|
||||||
{ name: 'Upload Files' },
|
{ name: 'Upload Files' },
|
||||||
{ name: 'Signature' },
|
{ name: 'Signature' },
|
||||||
|
{ name: 'Ban' },
|
||||||
];
|
];
|
||||||
|
|
||||||
privileges.global.userPrivilegeList = [
|
privileges.global.userPrivilegeList = [
|
||||||
@@ -24,6 +25,7 @@ module.exports = function (privileges) {
|
|||||||
'upload:post:image',
|
'upload:post:image',
|
||||||
'upload:post:file',
|
'upload:post:file',
|
||||||
'signature',
|
'signature',
|
||||||
|
'ban',
|
||||||
];
|
];
|
||||||
|
|
||||||
privileges.global.groupPrivilegeList = privileges.global.userPrivilegeList.map(function (privilege) {
|
privileges.global.groupPrivilegeList = privileges.global.userPrivilegeList.map(function (privilege) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
var async = require('async');
|
var async = require('async');
|
||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
|
|
||||||
var user = require('../user');
|
|
||||||
var groups = require('../groups');
|
var groups = require('../groups');
|
||||||
var plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
var helpers = require('./helpers');
|
var helpers = require('./helpers');
|
||||||
@@ -156,11 +155,8 @@ module.exports = function (privileges) {
|
|||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
isAdmin: function (next) {
|
canBan: function (next) {
|
||||||
privileges.users.isAdministrator(callerUid, next);
|
privileges.global.can('ban', callerUid, next);
|
||||||
},
|
|
||||||
isGlobalMod: function (next) {
|
|
||||||
privileges.users.isGlobalModerator(callerUid, next);
|
|
||||||
},
|
},
|
||||||
isTargetAdmin: function (next) {
|
isTargetAdmin: function (next) {
|
||||||
privileges.users.isAdministrator(uid, next);
|
privileges.users.isAdministrator(uid, next);
|
||||||
@@ -168,7 +164,7 @@ module.exports = function (privileges) {
|
|||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
results.canBan = !results.isTargetAdmin && (results.isAdmin || results.isGlobalMod);
|
results.canBan = !results.isTargetAdmin && results.canBan;
|
||||||
results.callerUid = callerUid;
|
results.callerUid = callerUid;
|
||||||
results.uid = uid;
|
results.uid = uid;
|
||||||
plugins.fireHook('filter:user.canBanUser', results, next);
|
plugins.fireHook('filter:user.canBanUser', results, next);
|
||||||
@@ -182,13 +178,12 @@ module.exports = function (privileges) {
|
|||||||
privileges.users.hasBanPrivilege = function (uid, callback) {
|
privileges.users.hasBanPrivilege = function (uid, callback) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
user.isAdminOrGlobalMod(uid, next);
|
privileges.global.can('ban', uid, next);
|
||||||
},
|
},
|
||||||
function (isAdminOrGlobalMod, next) {
|
function (canBan, next) {
|
||||||
plugins.fireHook('filter:user.hasBanPrivilege', {
|
plugins.fireHook('filter:user.hasBanPrivilege', {
|
||||||
uid: uid,
|
uid: uid,
|
||||||
isAdminOrGlobalMod: isAdminOrGlobalMod,
|
canBan: canBan,
|
||||||
canBan: isAdminOrGlobalMod,
|
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (data, next) {
|
function (data, next) {
|
||||||
|
|||||||
@@ -665,6 +665,7 @@ describe('Categories', function () {
|
|||||||
privileges.global.userPrivileges(1, function (err, data) {
|
privileges.global.userPrivileges(1, function (err, data) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.deepEqual(data, {
|
assert.deepEqual(data, {
|
||||||
|
ban: false,
|
||||||
chat: false,
|
chat: false,
|
||||||
'upload:post:image': false,
|
'upload:post:image': false,
|
||||||
'upload:post:file': false,
|
'upload:post:file': false,
|
||||||
@@ -702,6 +703,7 @@ describe('Categories', function () {
|
|||||||
privileges.global.groupPrivileges('registered-users', function (err, data) {
|
privileges.global.groupPrivileges('registered-users', function (err, data) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.deepEqual(data, {
|
assert.deepEqual(data, {
|
||||||
|
'groups:ban': false,
|
||||||
'groups:chat': true,
|
'groups:chat': true,
|
||||||
'groups:upload:post:image': true,
|
'groups:upload:post:image': true,
|
||||||
'groups:upload:post:file': false,
|
'groups:upload:post:file': false,
|
||||||
|
|||||||
Reference in New Issue
Block a user