Node.js based forum software built for the modern web
Merge branch 'master' into develop
Julian Lamaf2d9fb85b4f
diff --cc package.jsonindex 5aee89a816,def5528d63..658493068f--- a/package.json+++ b/package.json@@@ -52,8 -52,8 +52,8 @@@"morgan": "^1.3.2","mousetrap": "^1.5.3","nconf": "~0.8.2",- "nodebb-plugin-composer-default": "4.4.1",+ "nodebb-plugin-composer-default": "4.4.2",- "nodebb-plugin-dbsearch": "1.0.5",+ "nodebb-plugin-dbsearch": "2.0.2","nodebb-plugin-emoji-extended": "1.1.1","nodebb-plugin-emoji-one": "1.1.5","nodebb-plugin-markdown": "7.1.1",diff --cc src/middleware/index.jsindex 5a3f9aa5ba,faf2ad832d..de0bd6797e--- a/src/middleware/index.js+++ b/src/middleware/index.js@@@ -53,47 -53,26 +53,49 @@@ middleware.ensureSelfOrGlobalPrivilegeThe "self" part of this middleware hinges on you having usedmiddleware.exposeUid prior to invoking this middleware.*/- if (req.user) {- if (req.user.uid === res.locals.uid) {- return next();- }+ async.waterfall([+ function (next) {+ if (!req.uid) {+ return setImmediate(next, null, false);+ }- user.isAdminOrGlobalMod(req.uid, function (err, ok) {- if (err) {- return next(err);- } else if (ok) {- return next();+ if (req.uid === parseInt(res.locals.uid, 10)) {+ return setImmediate(next, null, true);}- controllers.helpers.notAllowed(req, res);- });- } else {- controllers.helpers.notAllowed(req, res);- }+ user.isAdminOrGlobalMod(req.uid, next);+ },+ function (isAdminOrGlobalMod, next) {+ if (!isAdminOrGlobalMod) {+ return controllers.helpers.notAllowed(req, res);+ }+ next();+ },+ ], next);};+middleware.ensureSelfOrPrivileged = function (req, res, next) {+ /*+ The "self" part of this middleware hinges on you having used+ middleware.exposeUid prior to invoking this middleware.+ */+ if (req.user) {+ if (parseInt(req.user.uid, 10) === parseInt(res.locals.uid, 10)) {+ return next();+ }++ user.isPrivileged(req.uid, function (err, ok) {+ if (err) {+ return next(err);+ } else if (ok) {+ return next();+ }+ controllers.helpers.notAllowed(req, res);+ });+ } else {+ controllers.helpers.notAllowed(req, res);+ }+};+middleware.pageView = function (req, res, next) {analytics.pageView({ip: req.ip,diff --cc src/user/data.jsindex 2dca1b4143,120da7e3a2..22810999f8--- a/src/user/data.js+++ b/src/user/data.js@@@ -63,17 -55,14 +64,28 @@@ module.exports = function (User)addField('lastonline');}++<<<<<<< HEAD+ db.getObjectsFields(keys, fields, function (err, users) {+ if (err) {+ return callback(err);+ }++ users = uids.map(function (uid) {+ return users[ref[uid]];+ });++ modifyUserData(users, fieldsToRemove, callback);+ });++=======+ async.waterfall([+ function (next) {+ db.getObjectsFields(keys, fields, next);+ },+ function (users, next) {+ modifyUserData(users, fieldsToRemove, next);+ },+ ], callback);++>>>>>>> master};User.getMultipleUserFields = function (uids, fields, callback) {@@@ -105,17 -85,14 +117,28 @@@return 'user:' + uid;});++<<<<<<< HEAD+ db.getObjects(keys, function (err, users) {+ if (err) {+ return callback(err);+ }++ users = uids.map(function (uid) {+ return users[ref[uid]];+ });++ modifyUserData(users, [], callback);+ });++=======+ async.waterfall([+ function (next) {+ db.getObjects(keys, next);+ },+ function (users, next) {+ modifyUserData(users, [], next);+ },+ ], callback);++>>>>>>> master};function modifyUserData(users, fieldsToRemove, callback) {diff --cc src/user/profile.jsindex 84c142f35b,ab7d9f9ae2..3071977949--- a/src/user/profile.js+++ b/src/user/profile.js@@@ -15,9 -15,14 +15,17 @@@ module.exports = function (User)var fields = ['username', 'email', 'fullname', 'website', 'location','groupTitle', 'birthday', 'signature', 'aboutme'];+ var updateUid = data.uid;+ var oldData;++ if (data.aboutme !== undefined && data.aboutme.length > meta.config.maximumAboutMeLength) {+ return callback(new Error('[[error:about-me-too-long, ' + meta.config.maximumAboutMeLength + ']]'));+ }++ if (data.signature !== undefined && data.signature.length > meta.config.maximumSignatureLength) {+ return callback(new Error('[[error:signature-too-long, ' + meta.config.maximumSignatureLength + ']]'));+ }+async.waterfall([function (next) {plugins.fireHook('filter:user.updateProfile', { uid: uid, data: data, fields: fields }, next);@@@ -27,10 -32,8 +35,8 @@@data = data.data;async.series([- async.apply(isAboutMeValid, data),- async.apply(isSignatureValid, data),- async.apply(isEmailAvailable, data, uid),- async.apply(isUsernameAvailable, data, uid),+ async.apply(isEmailAvailable, data, updateUid),+ async.apply(isUsernameAvailable, data, updateUid),async.apply(isGroupTitleValid, data),], function (err) {next(err);