From f5e41d53d221512263039877fed865e317e38185 Mon Sep 17 00:00:00 2001 From: Sahat Yalkabov Date: Thu, 5 Jun 2014 11:08:30 -0400 Subject: [PATCH] Fixed a returnTo bug Bumped version to 2.1.4 --- README.md | 6 +++++- app.js | 12 ++++++------ package.json | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d0b5eb9d33..75a305b2ae 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Hackathon Starter [![Dependency Status](http://img.shields.io/gemnasium/sahat/ha :octocat:  **Live Demo**: http://hackathonstarter.herokuapp.com -Jump to [What's new in 2.1.3?](#changelog) +Jump to [What's new in 2.1.4?](#changelog) A boilerplate for **Node.js** web applications. @@ -1134,6 +1134,10 @@ Add this to `package.json`, after *name* and *version*. This is necessary becaus Changelog --------- +### 2.1.4 (June 5, 2014) +- Fixed a bug related to `returnTo` url (#155) + + ### 2.1.3 (June 3, 2014) - Font Awesome 4.1 - Updated icons on some API examples diff --git a/app.js b/app.js index f8ce4b61a3..18e6aabd3a 100755 --- a/app.js +++ b/app.js @@ -90,21 +90,21 @@ app.use(passport.initialize()); app.use(passport.session()); app.use(flash()); app.use(function(req, res, next) { - // CSRF + // CSRF protection. if (whitelist.indexOf(req.path) !== -1) next(); else csrf(req, res, next); }); app.use(function(req, res, next) { - // Make current user available in templates + // Make user object available in templates. res.locals.user = req.user; next(); }); app.use(function(req, res, next) { - // Keep track of the previous URL so a user can redirect - // back to the original destination after a successful login. - if (req.method !== 'GET') return next(); + // Remember original destination before login. var path = req.path.split('/')[1]; - if (/(auth|login|logout|signup)$/i.test(path)) return next(); + if (/auth|login|logout|signup|img|fonts|favicon/i.test(path)) { + return next(); + } req.session.returnTo = req.path; next(); }); diff --git a/package.json b/package.json index d8055abe28..e2ae40a732 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hackathon-starter", - "version": "2.1.3", + "version": "2.1.4", "repository": { "type": "git", "url": "https://github.com/sahat/hackathon-starter.git"