Skip to content

Commit

Permalink
Final-LinterErrors-and-Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityanairaaq committed Sep 5, 2024
1 parent 67ac232 commit 6491083
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/middleware/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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........');
Expand All @@ -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........');
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 6491083

Please sign in to comment.