mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
refactor: shorter returns
This commit is contained in:
@@ -201,13 +201,11 @@ module.exports = function (middleware) {
|
|||||||
middleware.isAdmin = async function isAdmin(req, res, next) {
|
middleware.isAdmin = async function isAdmin(req, res, next) {
|
||||||
const isAdmin = await user.isAdministrator(req.uid);
|
const isAdmin = await user.isAdministrator(req.uid);
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
controllers.helpers.notAllowed(req, res);
|
return controllers.helpers.notAllowed(req, res);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const hasPassword = await user.hasPassword(req.uid);
|
const hasPassword = await user.hasPassword(req.uid);
|
||||||
if (!hasPassword) {
|
if (!hasPassword) {
|
||||||
next();
|
return next();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const loginTime = req.session.meta ? req.session.meta.datetime : 0;
|
const loginTime = req.session.meta ? req.session.meta.datetime : 0;
|
||||||
@@ -219,8 +217,7 @@ module.exports = function (middleware) {
|
|||||||
req.session.meta.datetime += Math.min(300000, adminReloginDuration);
|
req.session.meta.datetime += Math.min(300000, adminReloginDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
return next();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let returnTo = req.path;
|
let returnTo = req.path;
|
||||||
|
|||||||
Reference in New Issue
Block a user