v1.18.x
Baris Soner Usakli 11 years ago
parent dedf4add53
commit dc592853fc

@ -514,7 +514,7 @@ module.exports.server = server;
}); });
}); });
app.get('/topic/:topic_id/:slug?', function (req, res) { app.get('/topic/:topic_id/:slug?', function (req, res, next) {
var tid = req.params.topic_id; var tid = req.params.topic_id;
if (tid.match(/^\d+\.rss$/)) { if (tid.match(/^\d+\.rss$/)) {
@ -531,24 +531,33 @@ module.exports.server = server;
}; };
if (!fs.existsSync(rssPath)) { ThreadTools.privileges(tid, ((req.user) ? req.user.uid || 0 : 0), function(err, privileges) {
feed.updateTopic(tid, function (err) { if(err) {
if (err) { return next(err);
res.redirect('/404'); }
} else {
loadFeed(); if(!privileges.read) {
} return res.redirect('403');
}); }
} else {
loadFeed(); if (!fs.existsSync(rssPath)) {
} feed.updateTopic(tid, function (err) {
if (err) {
res.redirect('/404');
} else {
loadFeed();
}
});
} else {
loadFeed();
}
});
return; return;
} }
async.waterfall([ async.waterfall([
function(next) { function(next) {
// Check whether this user is allowed to access this topic
ThreadTools.privileges(tid, ((req.user) ? req.user.uid || 0 : 0), function(err, privileges) { ThreadTools.privileges(tid, ((req.user) ? req.user.uid || 0 : 0), function(err, privileges) {
if (!err) { if (!err) {
if (!privileges.read) { if (!privileges.read) {
@ -687,7 +696,7 @@ module.exports.server = server;
}); });
}); });
app.get('/category/:category_id/:slug?', function (req, res) { app.get('/category/:category_id/:slug?', function (req, res, next) {
var cid = req.params.category_id; var cid = req.params.category_id;
if (cid.match(/^\d+\.rss$/)) { if (cid.match(/^\d+\.rss$/)) {
@ -704,24 +713,33 @@ module.exports.server = server;
}; };
if (!fs.existsSync(rssPath)) { CategoryTools.privileges(cid, ((req.user) ? req.user.uid || 0 : 0), function(err, privileges) {
feed.updateCategory(cid, function (err) { if(err) {
if (err) { return next(err);
res.redirect('/404'); }
} else {
loadFeed(); if(!privileges.read) {
} return res.redirect('403');
}); }
} else {
loadFeed(); if (!fs.existsSync(rssPath)) {
} feed.updateCategory(cid, function (err) {
if (err) {
res.redirect('/404');
} else {
loadFeed();
}
});
} else {
loadFeed();
}
});
return; return;
} }
async.waterfall([ async.waterfall([
function(next) { function(next) {
// Check whether this user is allowed to access this category
CategoryTools.privileges(cid, ((req.user) ? req.user.uid || 0 : 0), function(err, privileges) { CategoryTools.privileges(cid, ((req.user) ? req.user.uid || 0 : 0), function(err, privileges) {
if (!err) { if (!err) {
if (!privileges.read) { if (!privileges.read) {

Loading…
Cancel
Save