Redirect back to previous page when visiting login and sign up pages after user is already logged in

This commit is contained in:
Sahat Yalkabov
2013-12-04 07:44:07 -05:00
parent 3c5f19a6d9
commit 83dbe9c197
5 changed files with 56 additions and 44 deletions

View File

@@ -160,7 +160,9 @@ passport.use(new GoogleStrategy({
// Simple route middleware to ensure user is authenticated. Otherwise send to login page.
exports.ensureAuthenticated = function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
if (req.isAuthenticated()) {
return next();
}
res.redirect('/login');
};