mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-15 05:54:22 +03:00
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.
This commit is contained in:
parent
bc3b8541ab
commit
063cf6a003
20
app.js
20
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
|
||||
|
Loading…
Reference in New Issue
Block a user