refactor: shorter returns

v1.18.x
Baris Usakli 5 years ago
parent efd1e88bbf
commit cec0079573

@ -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;

Loading…
Cancel
Save