Skip to content

Commit

Permalink
improve redirect after login
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Canta committed Apr 23, 2016
1 parent 4e40745 commit 3399bfd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3399bfd

Please sign in to comment.