Skip to content

Instantly share code, notes, and snippets.

@boutell
Created September 2, 2012 20:43
Show Gist options
  • Save boutell/3604375 to your computer and use it in GitHub Desktop.
Save boutell/3604375 to your computer and use it in GitHub Desktop.
// Why does this print 'Redirecting' but then send 'You are special' anyway?
function secure(req, res, next) {
if (!req.user) {
console.log('Redirecting');
req.session.afterLogin = req.url;
res.redirect('/login');
return;
}
else
{
next();
}
}
app.use(secure);
app.get('/', function(req, res) {
res.send("You are special");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment