0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Merge pull request #182 from jgable/suppressLoginNotification

Suppress login notification if navigating to /ghost
This commit is contained in:
Hannah Wolfe 2013-06-19 14:42:21 -07:00
commit 2621de54a0

20
app.js
View file

@ -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