mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
added req.uid user id for logged in users, 0 for guests
This commit is contained in:
@@ -12,7 +12,7 @@ groupsController.list = function(req, res, next) {
|
||||
groups.list({
|
||||
truncateUserList: true,
|
||||
expand: true,
|
||||
uid: req.user ? parseInt(req.user.uid, 10) : 0
|
||||
uid: req.uid
|
||||
}, function(err, groups) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -25,12 +25,12 @@ groupsController.list = function(req, res, next) {
|
||||
};
|
||||
|
||||
groupsController.details = function(req, res, next) {
|
||||
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
|
||||
|
||||
async.waterfall([
|
||||
async.apply(groups.exists, res.locals.groupName),
|
||||
function(exists, next) {
|
||||
if (!exists) { return next(undefined, null); }
|
||||
if (!exists) {
|
||||
return next(undefined, null);
|
||||
}
|
||||
|
||||
// Ensure the group isn't hidden either
|
||||
groups.isHidden(res.locals.groupName, next);
|
||||
@@ -43,8 +43,8 @@ groupsController.details = function(req, res, next) {
|
||||
} else {
|
||||
// If not, only members are granted access
|
||||
async.parallel([
|
||||
async.apply(groups.isMember, uid, res.locals.groupName),
|
||||
async.apply(groups.isInvited, uid, res.locals.groupName)
|
||||
async.apply(groups.isMember, req.uid, res.locals.groupName),
|
||||
async.apply(groups.isInvited, req.uid, res.locals.groupName)
|
||||
], function(err, checks) {
|
||||
next(err, checks[0] || checks[1]);
|
||||
});
|
||||
@@ -63,11 +63,11 @@ groupsController.details = function(req, res, next) {
|
||||
group: function(next) {
|
||||
groups.get(res.locals.groupName, {
|
||||
expand: true,
|
||||
uid: uid
|
||||
uid: req.uid
|
||||
}, next);
|
||||
},
|
||||
posts: function(next) {
|
||||
groups.getLatestMemberPosts(res.locals.groupName, 10, uid, next);
|
||||
groups.getLatestMemberPosts(res.locals.groupName, 10, req.uid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
@@ -84,13 +84,12 @@ groupsController.details = function(req, res, next) {
|
||||
};
|
||||
|
||||
groupsController.members = function(req, res, next) {
|
||||
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
groups.getGroupNameByGroupSlug(req.params.slug, next);
|
||||
},
|
||||
function(groupName, next) {
|
||||
user.getUsersFromSet('group:' + groupName + ':members', uid, 0, 49, next);
|
||||
user.getUsersFromSet('group:' + groupName + ':members', req.uid, 0, 49, next);
|
||||
},
|
||||
], function(err, users) {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user