more tests

This commit is contained in:
Barış Soner Uşaklı
2017-05-10 16:27:44 -04:00
parent 873801e9f3
commit 73f31640d7
4 changed files with 62 additions and 22 deletions

View File

@@ -1,19 +1,20 @@
'use strict';
var async = require('async');
var meta = require('../../meta');
var blacklistController = {};
var blacklistController = module.exports;
blacklistController.get = function (req, res, next) {
meta.blacklist.get(function (err, rules) {
if (err) {
return next(err);
}
res.render('admin/manage/ip-blacklist', {
rules: rules,
title: '[[pages:ip-blacklist]]',
});
});
async.waterfall([
function (next) {
meta.blacklist.get(next);
},
function (rules) {
res.render('admin/manage/ip-blacklist', {
rules: rules,
title: '[[pages:ip-blacklist]]',
});
},
], next);
};
module.exports = blacklistController;

View File

@@ -1,18 +1,22 @@
'use strict';
var async = require('async');
var user = require('../user');
var adminBlacklistController = require('./admin/blacklist');
var globalModsController = {};
var globalModsController = module.exports;
globalModsController.ipBlacklist = function (req, res, next) {
user.isAdminOrGlobalMod(req.uid, function (err, isAdminOrGlobalMod) {
if (err || !isAdminOrGlobalMod) {
return next(err);
}
adminBlacklistController.get(req, res, next);
});
async.waterfall([
function (next) {
user.isAdminOrGlobalMod(req.uid, next);
},
function (isAdminOrGlobalMod, next) {
if (!isAdminOrGlobalMod) {
return next();
}
adminBlacklistController.get(req, res, next);
},
], next);
};
module.exports = globalModsController;