function blockIfAuthenticated(req, res, next) {
  // If user is authenticated
  if (req.isAuthenticated()) {
    console.log("Redirect to index");
  }
  // Else redirect to login page
  console.log("Allow through");
  next();
}
// Custom middleware function that checks if a user is authenticated and if not, redirects to login
Custom middleware function that checks if a user is authenticated and if not, redirects to login
Custom middleware function that checks if a user is authenticated and if not redirects to login
function blockIfAuthenticated(req, res, next) {
  if (req.isAuthenticated()) {
    console.log("Redirect to index");
  }
  console.log("Allow through");
  next();
}
function blockIfAuthenticated ( req , res , next ) { if ( req . isAuthenticated ( ) ) { console . log ( "Redirect to index" ) ; } console . log ( "Allow through" ) ; next ( ) ; }
Custom middleware function that checks if a user is authenticated and if not, redirects to login
Custom middleware function that checks if a user is authenticated and if not redirects to login
// If user is authenticated // Else redirect to login page