mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-06 20:21:01 +01:00
fix(forums): fixed normal user and vip/oper only forum access issues
normal user cannot view the vip/oper forum topics in 'global topics' normal user can not view forum by url link enter, system well nav to forums home #40 #20
This commit is contained in:
@@ -138,7 +138,20 @@ exports.list = function (req, res) {
|
||||
* @param res
|
||||
*/
|
||||
exports.read = function (req, res) {
|
||||
res.json(req.forum);
|
||||
var forum = req.forum;
|
||||
var user = req.user;
|
||||
|
||||
if (forum.vipOnly && !user.isVip && !user.isOper) {
|
||||
return res.status(422).send({
|
||||
redirect: 'forums.list'
|
||||
});
|
||||
} else if (forum.operOnly && !user.isOper) {
|
||||
return res.status(422).send({
|
||||
redirect: 'forums.list'
|
||||
});
|
||||
} else {
|
||||
res.json(req.forum);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -280,6 +293,8 @@ exports.listTopics = function (req, res) {
|
||||
* @param res
|
||||
*/
|
||||
exports.globalTopics = function (req, res) {
|
||||
var user = req.user;
|
||||
|
||||
Forum.find().exec(function (err, forums) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
@@ -287,10 +302,16 @@ exports.globalTopics = function (req, res) {
|
||||
});
|
||||
} else {
|
||||
var ids = forums.map(function (el) {
|
||||
return el._id;
|
||||
if (el.vipOnly && !user.isVip && !user.isOper) {
|
||||
return undefined;
|
||||
} else if (el.operOnly && !user.isOper) {
|
||||
return undefined;
|
||||
} else {
|
||||
return el._id;
|
||||
}
|
||||
});
|
||||
|
||||
console.log(ids);
|
||||
//console.log(ids);
|
||||
|
||||
Topic.find({
|
||||
isGlobal: true,
|
||||
|
||||
Reference in New Issue
Block a user