Merge branch 'master' into v0.8.x

This commit is contained in:
Julian Lam
2015-08-27 16:49:49 -04:00
3 changed files with 23 additions and 7 deletions

View File

@@ -19,18 +19,34 @@ helpers.notFound = function(req, res, error) {
error: error
});
} else if (res.locals.isAPI) {
res.status(404).json({path: req.path.replace(/^\/api/, ''), error: error});
res.status(404).json({
path: req.path.replace(/^\/api/, ''),
error: error,
title: '[[global:404.title]]'
});
} else {
res.status(404).render('404', {path: req.path, error: error});
res.status(404).render('404', {
path: req.path,
error: error,
title: '[[global:404.title]]'
});
}
};
helpers.notAllowed = function(req, res, error) {
if (req.uid) {
if (res.locals.isAPI) {
res.status(403).json({path: req.path.replace(/^\/api/, ''), loggedIn: !!req.uid, error: error});
res.status(403).json({
path: req.path.replace(/^\/api/, ''),
loggedIn: !!req.uid, error: error,
title: '[[global:403.title]]'
});
} else {
res.status(403).render('403', {path: req.path, loggedIn: !!req.uid, error: error});
res.status(403).render('403', {
path: req.path,
loggedIn: !!req.uid, error: error,
title: '[[global:403.title]]'
});
}
} else {
if (res.locals.isAPI) {

View File

@@ -519,7 +519,7 @@ middleware.requireUser = function(req, res, next) {
return next();
}
res.render('403', {});
res.render('403', {title: '[[global:403.title]]'});
};
function redirectToLogin(req, res) {

View File

@@ -189,11 +189,11 @@ function handle404(app, middleware) {
res.status(404);
if (res.locals.isAPI) {
return res.json({path: req.path});
return res.json({path: req.path, title: '[[global:404.title]]'});
}
middleware.buildHeader(req, res, function() {
res.render('404', {path: req.path});
res.render('404', {path: req.path, title: '[[global:404.title]]'});
});
} else {
res.status(404).type('txt').send('Not found');