Skip to content

Node.js based forum software built for the modern web

moved category redirect up

barisusakli9023060008f5
diff --git a/src/controllers/categories.js b/src/controllers/categories.js
index 49890ab6f7..40b87f4db4 100644
--- a/src/controllers/categories.js
+++ b/src/controllers/categories.js
@@ -165,24 +165,21 @@ categoriesController.get = function(req, res, next) {
});
},
function(payload, next) {
- // If a userslug was specified, add a targetUid
- if (req.query.author) {
- user.getUidByUserslug(req.query.author, function(err, uid) {
- payload.targetUid = uid;
- next(err, payload);
- });
- } else {
- next(null, payload);
- }
+ user.getUidByUserslug(req.query.author, function(err, uid) {
+ payload.targetUid = uid;
+ next(err, payload);
+ });
+ },
+ function(payload, next) {
+ categories.getCategoryById(payload, next);
},
- categories.getCategoryById,
function(categoryData, next) {
- categories.getRecentTopicReplies(categoryData.children, uid, function(err) {
- if (err) {
- return next(err);
- }
+ if (categoryData.link) {
+ return res.redirect(categoryData.link);
+ }
- next(null, categoryData);
+ categories.getRecentTopicReplies(categoryData.children, uid, function(err) {
+ next(err, categoryData);
});
},
function (categoryData, next) {
@@ -233,10 +230,6 @@ categoriesController.get = function(req, res, next) {
return next(err);
}
- if (data.link) {
- return res.redirect(data.link);
- }
-
data.currentPage = page;
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
diff --git a/src/user.js b/src/user.js
index 20e2fc69f3..b89f91ec6e 100644
--- a/src/user.js
+++ b/src/user.js
@@ -286,10 +286,16 @@ var async = require('async'),
};
User.getUidByUsername = function(username, callback) {
+ if (!username) {
+ return callback();
+ }
db.getObjectField('username:uid', username, callback);
};
User.getUidByUserslug = function(userslug, callback) {
+ if (!userslug) {
+ return callback();
+ }
db.getObjectField('userslug:uid', userslug, callback);
};