feat: banned-users group

This commit is contained in:
gasoved
2020-12-14 09:20:41 +03:00
committed by Julian Lam
parent 389690c3fa
commit 53e0d4d2e0
24 changed files with 350 additions and 114 deletions

View File

@@ -32,13 +32,13 @@ const relative_path = nconf.get('relative_path');
middleware.buildHeader = helpers.try(async function buildHeader(req, res, next) {
res.locals.renderHeader = true;
res.locals.isAPI = false;
const [config, isBanned] = await Promise.all([
const [config, canLoginIfBanned] = await Promise.all([
controllers.api.loadConfig(req),
user.bans.isBanned(req.uid),
user.bans.canLoginIfBanned(req.uid),
plugins.hooks.fire('filter:middleware.buildHeader', { req: req, locals: res.locals }),
]);
if (isBanned) {
if (!canLoginIfBanned && req.loggedIn) {
req.logout();
return res.redirect('/');
}