mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-25 03:31:14 +02:00
Merge branch 'master' into v0.8.x
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user