diff --git a/src/routes/api.js b/src/routes/api.js index 38b29f11fd..bedb3da528 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -119,7 +119,7 @@ var path = require('path'), var motdString, assemble = function() { data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none'; - data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default'); + data.motd_class += (meta.config.motd && meta.config.motd.length > 0) ? '' : ' default'; data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : ''; data.motd = motdString; diff --git a/src/user.js b/src/user.js index 0b0d9a3315..b2d6f9ee24 100644 --- a/src/user.js +++ b/src/user.js @@ -216,7 +216,16 @@ var bcrypt = require('bcryptjs'), } User.saveSettings = function(uid, data, callback) { - db.setObject('user:' + uid + ':settings', data, callback); + if(!data.topicsPerPage || !data.postsPerPage || parseInt(data.topicsPerPage, 10) <= 0 || !parseInt(data.postsPerPage, 10) <= 0) { + return callback(new Error('Invalid pagination value!')); + } + + db.setObject('user:' + uid + ':settings', { + showemail: data.showemail, + usePagination: data.usePagination, + topicsPerPage: data.topicsPerPage, + postsPerPage: data.postsPerPage + }, callback); } User.updateProfile = function(uid, data, callback) {