function allowThroughIfAuthenticated(req, res, next) {
  console.log("Login status: " + req.isAuthenticated());
  // If user is authenticated
  if (req.isAuthenticated()) {
    console.log("Allowing through to requested page");
    // Return callback function
    return next();
  }
  // Else redirect to login page
  console.log("Redirect to login page");
  // res.redirect("/login");
}
// Custom middleware function that checks if a user is authenticated to continue, and if not, redirects to login
Custom middleware function that checks if a user is authenticated to continue, and if not, redirects to login
Custom middleware function that checks if a user is authenticated to continue and if not redirects to login
function allowThroughIfAuthenticated(req, res, next) {
  console.log("Login status: " + req.isAuthenticated());
  if (req.isAuthenticated()) {
    console.log("Allowing through to requested page");
    return next();
  }
  console.log("Redirect to login page");
}
function allowThroughIfAuthenticated ( req , res , next ) { console . log ( "Login status: " + req . isAuthenticated ( ) ) ; if ( req . isAuthenticated ( ) ) { console . log ( "Allowing through to requested page" ) ; return next ( ) ; } console . log ( "Redirect to login page" ) ; }
Custom middleware function that checks if a user is authenticated to continue, and if not, redirects to login
Custom middleware function that checks if a user is authenticated to continue and if not redirects to login
// If user is authenticated // Return callback function // Else redirect to login page // res.redirect("/login");