From 063cf6a003366316a5779f13b6c37a650688c371 Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Sun, 16 Jun 2013 19:46:13 -0500 Subject: [PATCH] Suppress login notification if navigating to /ghost Added a simple regex check of the requesting url. Put a placeholder in in case you want to do some more checking and show a different message. Should close #135. --- app.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 0234f99fc1..14ef5d6edf 100755 --- a/app.js +++ b/app.js @@ -46,20 +46,30 @@ }); /** - * Setup login details - * p.s. love it. + * Authenticate a request by redirecting to login if not logged in * * @type {*} */ auth = function (req, res, next) { if (!req.session.user) { - req.flash('warn', "Please login"); - res.redirect('/ghost/login/?redirect=' + encodeURIComponent(req.path)); - return; + if (req.url && /^\/ghost\/?$/gi.test(req.url)) { + // TODO: Welcome message? Intro if no logins yet? + req.shutUpJsLint = true; + } else { + req.flash('warn', "Please login"); + } + + return res.redirect('/ghost/login/?redirect=' + encodeURIComponent(req.path)); } + next(); }; + /** + * Authenticate a request by responding with a 401 and json error details + * + * @type {*} + */ authAPI = function (req, res, next) { if (!req.session.user) { // TODO: standardize error format/codes/messages