From 3399bfd0535f83de6525ec6d987699d7a253e3ee Mon Sep 17 00:00:00 2001 From: Andrei Canta Date: Sat, 23 Apr 2016 16:30:31 +0300 Subject: [PATCH] improve redirect after login --- app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index c34d2e364f..be16e8ed0f 100644 --- a/app.js +++ b/app.js @@ -95,8 +95,12 @@ app.use(function(req, res, next) { next(); }); app.use(function(req, res, next) { - // After successful login, redirect back to /api, /contact or / - if (/(api)|(contact)|(^\/$)/i.test(req.path)) { + // After successful login, redirect back to the intended page + if (req.user == undefined && + req.path !== '/login' && + req.path !== '/signup' && + !req.path.match(/^\/auth/) && + !req.path.match(/\./)) { req.session.returnTo = req.path; } next();