From ad9209ec38b0ec30530d14e7f2ca3343a210177f Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 11 Feb 2014 17:56:24 -0500 Subject: [PATCH] modifying user.getSettings / user.saveSettings to allow passing in custom data --- src/user.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/user.js b/src/user.js index 26d0a19f98..41527b6ed9 100644 --- a/src/user.js +++ b/src/user.js @@ -204,29 +204,23 @@ var bcrypt = require('bcryptjs'), } if(!settings) { - return sendDefaultSettings(); + settings = {} } - settings.showemail = parseInt(settings.showemail, 10) !== 0; - settings.usePagination = parseInt(settings.usePagination, 10) !== 0; - settings.topicsPerPage = parseInt(settings.topicsPerPage, 10); - settings.postsPerPage = parseInt(settings.postsPerPage, 10); + settings.showemail = settings.showemail ? parseInt(settings.showemail, 10) !== 0 : parseInt(meta.config.usePagination, 10) !== 0; + settings.usePagination = settings.usePagination ? parseInt(settings.usePagination, 10) !== 0 : parseInt(meta.config.usePagination, 10) !== 0; + settings.topicsPerPage = settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : parseInt(meta.config.topicsPerPage, 10) || 20; + settings.postsPerPage = settings.postsPerPage ? parseInt(settings.postsPerPage, 10) : parseInt(meta.config.postsPerPage, 10) || 10; callback(null, settings); }); } User.saveSettings = function(uid, data, callback) { - db.setObject('user:' + uid + ':settings', { - showemail: data.showemail || 0, - usePagination: data.usePagination || 0, - topicsPerPage: data.topicsPerPage || 20, - postsPerPage: data.postsPerPage || 10 - }, callback); + db.setObject('user:' + uid + ':settings', data, callback); } User.updateProfile = function(uid, data, callback) { - var fields = ['username', 'email', 'fullname', 'website', 'location', 'birthday', 'signature']; var returnData = { success: false