From 13657a04cb0b377b1dcbd68deaad9e6744eff174 Mon Sep 17 00:00:00 2001 From: fatchan Date: Thu, 20 Feb 2020 08:41:33 +0100 Subject: [PATCH] small fix check in hasperms --- helpers/checks/hasperms.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/helpers/checks/hasperms.js b/helpers/checks/hasperms.js index 6f7c11df..547feeae 100644 --- a/helpers/checks/hasperms.js +++ b/helpers/checks/hasperms.js @@ -1,16 +1,18 @@ 'use strict'; module.exports = (req, res) => { - const { authenticated, user } = req.session; - if (authenticated === true && user != null) { - if (user.authLevel < 4) { //assigned levels - return user.authLevel; - } - if (res.locals.board != null) { - if (res.locals.board.owner === user.username) { - return 2; //board owner 2 - } else if (res.locals.board.settings.moderators.includes(user.username) === true) { - return 3; //board staff 3 + if (req.session) { + const { authenticated, user } = req.session; + if (authenticated === true && user != null) { + if (user.authLevel < 4) { //assigned levels + return user.authLevel; + } + if (res.locals.board != null) { + if (res.locals.board.owner === user.username) { + return 2; //board owner 2 + } else if (res.locals.board.settings.moderators.includes(user.username) === true) { + return 3; //board staff 3 + } } } }