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 Files' },
|
||||
{ name: 'Signature' },
|
||||
{ name: 'Ban' },
|
||||
];
|
||||
|
||||
privileges.global.userPrivilegeList = [
|
||||
@@ -24,6 +25,7 @@ module.exports = function (privileges) {
|
||||
'upload:post:image',
|
||||
'upload:post:file',
|
||||
'signature',
|
||||
'ban',
|
||||
];
|
||||
|
||||
privileges.global.groupPrivilegeList = privileges.global.userPrivilegeList.map(function (privilege) {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
var async = require('async');
|
||||
var _ = require('lodash');
|
||||
|
||||
var user = require('../user');
|
||||
var groups = require('../groups');
|
||||
var plugins = require('../plugins');
|
||||
var helpers = require('./helpers');
|
||||
@@ -156,11 +155,8 @@ module.exports = function (privileges) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
isAdmin: function (next) {
|
||||
privileges.users.isAdministrator(callerUid, next);
|
||||
},
|
||||
isGlobalMod: function (next) {
|
||||
privileges.users.isGlobalModerator(callerUid, next);
|
||||
canBan: function (next) {
|
||||
privileges.global.can('ban', callerUid, next);
|
||||
},
|
||||
isTargetAdmin: function (next) {
|
||||
privileges.users.isAdministrator(uid, next);
|
||||
@@ -168,7 +164,7 @@ module.exports = function (privileges) {
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
results.canBan = !results.isTargetAdmin && (results.isAdmin || results.isGlobalMod);
|
||||
results.canBan = !results.isTargetAdmin && results.canBan;
|
||||
results.callerUid = callerUid;
|
||||
results.uid = uid;
|
||||
plugins.fireHook('filter:user.canBanUser', results, next);
|
||||
@@ -182,13 +178,12 @@ module.exports = function (privileges) {
|
||||
privileges.users.hasBanPrivilege = function (uid, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.isAdminOrGlobalMod(uid, next);
|
||||
privileges.global.can('ban', uid, next);
|
||||
},
|
||||
function (isAdminOrGlobalMod, next) {
|
||||
function (canBan, next) {
|
||||
plugins.fireHook('filter:user.hasBanPrivilege', {
|
||||
uid: uid,
|
||||
isAdminOrGlobalMod: isAdminOrGlobalMod,
|
||||
canBan: isAdminOrGlobalMod,
|
||||
canBan: canBan,
|
||||
}, next);
|
||||
},
|
||||
function (data, next) {
|
||||
|
||||
@@ -665,6 +665,7 @@ describe('Categories', function () {
|
||||
privileges.global.userPrivileges(1, function (err, data) {
|
||||
assert.ifError(err);
|
||||
assert.deepEqual(data, {
|
||||
ban: false,
|
||||
chat: false,
|
||||
'upload:post:image': false,
|
||||
'upload:post:file': false,
|
||||
@@ -702,6 +703,7 @@ describe('Categories', function () {
|
||||
privileges.global.groupPrivileges('registered-users', function (err, data) {
|
||||
assert.ifError(err);
|
||||
assert.deepEqual(data, {
|
||||
'groups:ban': false,
|
||||
'groups:chat': true,
|
||||
'groups:upload:post:image': true,
|
||||
'groups:upload:post:file': false,
|
||||
|
||||
Reference in New Issue
Block a user