mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
684 B
22 lines
684 B
'use strict';
|
|
|
|
const Bans = require(__dirname+'/../../db/bans.js')
|
|
, hasPerms = require(__dirname+'/hasperms.js');
|
|
|
|
module.exports = async (req, res, next) => {
|
|
|
|
if (res.locals.permLevel > 1) {//global staff or admin bypass
|
|
const bans = await Bans.find(res.locals.ip, res.locals.board ? res.locals.board._id : null);
|
|
if (bans && bans.length > 0) {
|
|
const globalBans = bans.filter(ban => { return board === null });
|
|
if (globalBans.length > 0 || (res.locals.permLevel >= 4 && globalBans.length !== bans.length)) {
|
|
//board staff bypass bans on their own board, but not global bans
|
|
return res.status(403).render('ban', {
|
|
bans: bans
|
|
});
|
|
}
|
|
}
|
|
}
|
|
next();
|
|
|
|
}
|
|
|