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:
commit
2621de54a0
1 changed files with 15 additions and 5 deletions
20
app.js
20
app.js
|
@ -46,20 +46,30 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup login details
|
* Authenticate a request by redirecting to login if not logged in
|
||||||
* p.s. love it.
|
|
||||||
*
|
*
|
||||||
* @type {*}
|
* @type {*}
|
||||||
*/
|
*/
|
||||||
auth = function (req, res, next) {
|
auth = function (req, res, next) {
|
||||||
if (!req.session.user) {
|
if (!req.session.user) {
|
||||||
req.flash('warn', "Please login");
|
if (req.url && /^\/ghost\/?$/gi.test(req.url)) {
|
||||||
res.redirect('/ghost/login/?redirect=' + encodeURIComponent(req.path));
|
// TODO: Welcome message? Intro if no logins yet?
|
||||||
return;
|
req.shutUpJsLint = true;
|
||||||
|
} else {
|
||||||
|
req.flash('warn', "Please login");
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.redirect('/ghost/login/?redirect=' + encodeURIComponent(req.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticate a request by responding with a 401 and json error details
|
||||||
|
*
|
||||||
|
* @type {*}
|
||||||
|
*/
|
||||||
authAPI = function (req, res, next) {
|
authAPI = function (req, res, next) {
|
||||||
if (!req.session.user) {
|
if (!req.session.user) {
|
||||||
// TODO: standardize error format/codes/messages
|
// TODO: standardize error format/codes/messages
|
||||||
|
|
Loading…
Add table
Reference in a new issue