diff --git a/src/controllers/admin/users.js b/src/controllers/admin/users.js index 6bd64ef23b..4cf53b79bd 100644 --- a/src/controllers/admin/users.js +++ b/src/controllers/admin/users.js @@ -13,48 +13,31 @@ usersController.search = function(req, res, next) { }); }; -usersController.latest = function(req, res, next) { - user.getUsers('users:joindate', 0, 49, function(err, users) { - res.render('admin/users', { - search_display: 'none', - loadmore_display: 'block', - users: users, - yourid: req.user.uid - }); - }); -}; - usersController.sortByPosts = function(req, res, next) { - user.getUsers('users:postcount', 0, 49, function(err, users) { - res.render('admin/users', { - search_display: 'none', - loadmore_display: 'block', - users: users, - yourid: req.user.uid - }); - }); + getUsers('users:postcount', req, res, next); }; usersController.sortByReputation = function(req, res, next) { - user.getUsers('users:reputation', 0, 49, function(err, users) { - res.render('admin/users', { - search_display: 'none', - loadmore_display: 'block', - users: users, - yourid: req.user.uid - }); - }); + getUsers('users:reputation', req, res, next); }; usersController.sortByJoinDate = function(req, res, next) { - user.getUsers('users:joindate', 0, 49, function(err, users) { + getUsers('users:joindate', req, res, next); +}; + +function getUsers(set, req, res, next) { + user.getUsers(set, 0, 49, function(err, users) { + if (err) { + return next(err); + } res.render('admin/users', { search_display: 'none', + loadmore_display: 'block', users: users, yourid: req.user.uid }); }); -}; +} usersController.getCSV = function(req, res, next) { user.getUsersCSV(function(err, data) { diff --git a/src/routes/admin.js b/src/routes/admin.js index a75e7d1d16..647dd5f54e 100644 --- a/src/routes/admin.js +++ b/src/routes/admin.js @@ -26,8 +26,8 @@ function userRoutes(app, middleware, controllers) { app.get('/admin/users/search', middleware.admin.buildHeader, controllers.admin.users.search); app.get('/api/admin/users/search', controllers.admin.users.search); - app.get('/admin/users/latest', middleware.admin.buildHeader, controllers.admin.users.latest); - app.get('/api/admin/users/latest', controllers.admin.users.latest); + app.get('/admin/users/latest', middleware.admin.buildHeader, controllers.admin.users.sortByJoinDate); + app.get('/api/admin/users/latest', controllers.admin.users.sortByJoinDate); app.get('/admin/users/sort-posts', middleware.admin.buildHeader, controllers.admin.users.sortByPosts); app.get('/api/admin/users/sort-posts', controllers.admin.users.sortByPosts); @@ -76,7 +76,7 @@ module.exports = function(app, middleware, controllers) { app.all('/api/admin/*', middleware.admin.isAdmin, middleware.prepareAPI); app.all('/admin/*', middleware.admin.isAdmin); app.get('/admin', middleware.admin.isAdmin); - + mainRoutes(app, middleware, controllers); userRoutes(app, middleware, controllers); forumRoutes(app, middleware, controllers); diff --git a/src/socket.io/index.js b/src/socket.io/index.js index 9d55c874aa..bdd017a4c3 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -67,15 +67,8 @@ Sockets.init = function(server) { socket.uid = parseInt(uid, 10); - /* Need to save some state for the logger & maybe some other modules later on */ - socket.state = { - user : { - uid : uid - } - }; - /* If meta.config.loggerIOStatus > 0, logger.io_one will hook into this socket */ - logger.io_one(socket,uid); + logger.io_one(socket, uid); if (uid) {