mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
closed #2087
This commit is contained in:
@@ -32,10 +32,11 @@ $(document).ready(function() {
|
|||||||
if (data) {
|
if (data) {
|
||||||
if (data.status === 404) {
|
if (data.status === 404) {
|
||||||
return ajaxify.go('404');
|
return ajaxify.go('404');
|
||||||
} else if (data.status === 403) {
|
} else if (data.status === 401) {
|
||||||
app.alertError('[[global:please_log_in]]');
|
app.alertError('[[global:please_log_in]]');
|
||||||
app.previousUrl = url;
|
|
||||||
return ajaxify.go('login');
|
return ajaxify.go('login');
|
||||||
|
} else if (data.statuc === 403) {
|
||||||
|
app.alertError('[[error:no-privileges]]');
|
||||||
} else if (data.status === 302) {
|
} else if (data.status === 302) {
|
||||||
return ajaxify.go(data.responseJSON.slice(1), callback, quiet);
|
return ajaxify.go(data.responseJSON.slice(1), callback, quiet);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ var categoriesController = {},
|
|||||||
meta = require('../meta'),
|
meta = require('../meta'),
|
||||||
plugins = require('../plugins');
|
plugins = require('../plugins');
|
||||||
|
|
||||||
|
// todo: This might be better placed somewhere else
|
||||||
|
var apiToRegular = function(url) {
|
||||||
|
return url.replace(/^\/api/, '');
|
||||||
|
};
|
||||||
|
|
||||||
categoriesController.recent = function(req, res, next) {
|
categoriesController.recent = function(req, res, next) {
|
||||||
var uid = req.user ? req.user.uid : 0;
|
var uid = req.user ? req.user.uid : 0;
|
||||||
var end = (parseInt(meta.config.topicsPerList, 10) || 20) - 1;
|
var end = (parseInt(meta.config.topicsPerList, 10) || 20) - 1;
|
||||||
@@ -231,6 +236,7 @@ categoriesController.notAllowed = function(req, res) {
|
|||||||
res.locals.isAPI ? res.json(403, 'not-allowed') : res.status(403).render('403');
|
res.locals.isAPI ? res.json(403, 'not-allowed') : res.status(403).render('403');
|
||||||
} else {
|
} else {
|
||||||
if (res.locals.isAPI) {
|
if (res.locals.isAPI) {
|
||||||
|
req.session.returnTo = apiToRegular(req.url);
|
||||||
res.json(401, 'not-authorized');
|
res.json(401, 'not-authorized');
|
||||||
} else {
|
} else {
|
||||||
req.session.returnTo = req.url;
|
req.session.returnTo = req.url;
|
||||||
|
|||||||
Reference in New Issue
Block a user