dont add category/topic slug if user doesnt have read permission

or category is disabled etc.
This commit is contained in:
barisusakli
2015-04-08 21:16:06 -04:00
parent 0c851d864e
commit 835d4db481
4 changed files with 12 additions and 25 deletions

View File

@@ -43,7 +43,7 @@ topicsController.get = function(req, res, next) {
function (results, next) {
userPrivileges = results.privileges;
if (userPrivileges.disabled || tid + '/' + req.params.slug !== results.topic.slug) {
if (userPrivileges.disabled || (req.params.slug && tid + '/' + req.params.slug !== results.topic.slug)) {
return helpers.notFound(req, res);
}
@@ -51,6 +51,10 @@ topicsController.get = function(req, res, next) {
return helpers.notAllowed(req, res);
}
if (!req.params.slug && results.topic.slug && results.topic.slug !== tid + '/') {
return helpers.redirect(res, '/topic/' + encodeURI(results.topic.slug));
}
var settings = results.settings;
var postCount = parseInt(results.topic.postcount, 10);
var pageCount = Math.max(1, Math.ceil((postCount - 1) / settings.postsPerPage));