dont allow negative or zero pagination values for user setting

v1.18.x
Baris Soner Usakli 11 years ago
parent ccfa5bd618
commit 7b4f098cb4

@ -119,7 +119,7 @@ var path = require('path'),
var motdString, var motdString,
assemble = function() { assemble = function() {
data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none'; 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_class += meta.config.motd_class ? ' ' + meta.config.motd_class : '';
data.motd = motdString; data.motd = motdString;

@ -216,7 +216,16 @@ var bcrypt = require('bcryptjs'),
} }
User.saveSettings = function(uid, data, callback) { 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) { User.updateProfile = function(uid, data, callback) {

Loading…
Cancel
Save