Add privilege for accessing user information (#7859)
* Add view users info global privilege * Show user ip only to global mods and admins * fix missing comma * Hide link for users without correct privilege * move getting privilege information to getAllData * Hide the link from Global Moderators as well * Give Global Moderator view:users:info privilege * Restrict ip in post menu to view:users:info * add some trailing commas.... * Add privilege to categories test * Add group privilege to categories test * add upgrade script * fix style for TravisCI * more styling - change spaces to tabs * some more styling fixes (hopefully final one) * fix style for Travis CI * hide ip in chat messages * Don't show even hidden ips on user profile pagev1.18.x
parent
781b3f1a9a
commit
b9583ed838
@ -0,0 +1,45 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var async = require('async');
|
||||||
|
var db = require('../../database');
|
||||||
|
var privileges = require('../../privileges');
|
||||||
|
var groups = require('../../groups');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'give mod info privilege',
|
||||||
|
timestamp: Date.UTC(2019, 9, 8),
|
||||||
|
method: function (callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
db.getSortedSetRevRange('categories:cid', 0, -1, next);
|
||||||
|
},
|
||||||
|
function (cids, next) {
|
||||||
|
async.eachSeries(cids, function (cid, next) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
givePrivsToModerators(cid, '', next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
givePrivsToModerators(cid, 'groups:', next);
|
||||||
|
},
|
||||||
|
], next);
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
privileges.global.give(['view:users:info'], 'Global Moderators', next);
|
||||||
|
},
|
||||||
|
], callback);
|
||||||
|
function givePrivsToModerators(cid, groupPrefix, callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
db.getSortedSetRevRange('group:cid:' + cid + ':privileges:' + groupPrefix + 'moderate:members', 0, -1, next);
|
||||||
|
},
|
||||||
|
function (members, next) {
|
||||||
|
async.eachSeries(members, function (member, next) {
|
||||||
|
groups.join(['cid:0:privileges:view:users:info'], member, next);
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
|
], callback);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue