diff --git a/src/middleware/admin.js b/src/middleware/admin.js index b57e8f2a5b..b5961567b1 100644 --- a/src/middleware/admin.js +++ b/src/middleware/admin.js @@ -52,7 +52,7 @@ middleware.checkPrivileges = helpers.try(async (req, res, next) => { } }); -// Function to check if the user is a guest +// check if the user is a guest function isGuest(req, res) { if (req.uid <= 0) { console.log('>>Instance Ran........'); @@ -63,7 +63,8 @@ function isGuest(req, res) { return false; } -// Function to check if the user has the necessary privilege for the requested path +// check if the user has the necessary privilege for the requested path +// code creation assisted async function hasPrivilegeForPath(req, path) { if (path) { console.log('>>PrevPath Check........'); @@ -75,13 +76,14 @@ async function hasPrivilegeForPath(req, path) { return Object.values(privilegeSet).some(Boolean); } -// Function to check if the user has a password +// check if the user has password async function userHasPassword(req) { console.log('>>Pass Check Ran........'); return await user.hasPassword(req.uid); } -// Function to determine if the user needs to re-login +// determine if the user needs to relogin or not +// code creation assisted function shouldRelogin(req) { console.log('>>Relog Check Ran........'); const loginTime = req.session.meta ? req.session.meta.datetime : 0; @@ -90,7 +92,8 @@ function shouldRelogin(req) { (loginTime && parseInt(loginTime, 10) > Date.now() - adminReloginDuration)); } -// Function to handle user re-login +// handle relogin if necessary +// code creation assisted async function handleRelogin(req, res) { console.log('>>HandleReLogin Ran........'); let returnTo = req.path; @@ -113,9 +116,10 @@ async function handleRelogin(req, res) { } } -// Function to extend the user's logout timer +// extend the user's logout timer +// code creation assisted function extendLogoutTimer(req) { - console.log('>>Instance Ran........'); + console.log('>>Extend Ran........'); const loginTime = req.session.meta ? req.session.meta.datetime : 0; const adminReloginDuration = meta.config.adminReloginDuration * 60000; const timeLeft = parseInt(loginTime, 10) - (Date.now() - adminReloginDuration);