|
|
@ -11,8 +11,20 @@ var plugins = require('../plugins');
|
|
|
|
var utils = require('../utils');
|
|
|
|
var utils = require('../utils');
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function (User) {
|
|
|
|
module.exports = function (User) {
|
|
|
|
var iconBackgrounds = ['#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3',
|
|
|
|
var iconBackgrounds = [
|
|
|
|
'#009688', '#1b5e20', '#33691e', '#827717', '#e65100', '#ff5722', '#795548', '#607d8b'];
|
|
|
|
'#f44336', '#e91e63', '#9c27b0', '#673ab7', '#3f51b5', '#2196f3',
|
|
|
|
|
|
|
|
'#009688', '#1b5e20', '#33691e', '#827717', '#e65100', '#ff5722',
|
|
|
|
|
|
|
|
'#795548', '#607d8b',
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fieldWhitelist = [
|
|
|
|
|
|
|
|
'uid', 'username', 'userslug', 'email', 'email:confirmed', 'joindate',
|
|
|
|
|
|
|
|
'lastonline', 'picture', 'fullname', 'location', 'birthday', 'website',
|
|
|
|
|
|
|
|
'aboutme', 'signature', 'uploadedpicture', 'profileviews', 'reputation',
|
|
|
|
|
|
|
|
'postcount', 'topiccount', 'lastposttime', 'banned', 'banned:expire',
|
|
|
|
|
|
|
|
'status', 'flags', 'followerCount', 'followingCount', 'cover:url',
|
|
|
|
|
|
|
|
'cover:position', 'groupTitle',
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
User.getUserField = function (uid, field, callback) {
|
|
|
|
User.getUserField = function (uid, field, callback) {
|
|
|
|
User.getUserFields(uid, [field], function (err, user) {
|
|
|
|
User.getUserFields(uid, [field], function (err, user) {
|
|
|
@ -48,7 +60,6 @@ module.exports = function (User) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.indexOf('picture') !== -1) {
|
|
|
|
if (fields.indexOf('picture') !== -1) {
|
|
|
|
addField('email');
|
|
|
|
|
|
|
|
addField('uploadedpicture');
|
|
|
|
addField('uploadedpicture');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -62,11 +73,18 @@ module.exports = function (User) {
|
|
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
function (next) {
|
|
|
|
function (next) {
|
|
|
|
|
|
|
|
plugins.fireHook('filter:user.whitelistFields', { uids: uids, whitelist: fieldWhitelist.slice() }, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function (results, next) {
|
|
|
|
if (fields.length) {
|
|
|
|
if (fields.length) {
|
|
|
|
db.getObjectsFields(uidsToUserKeys(uniqueUids), fields, next);
|
|
|
|
fields = fields.filter(function (field) {
|
|
|
|
|
|
|
|
return field && results.whitelist.includes(field);
|
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
db.getObjects(uidsToUserKeys(uniqueUids), next);
|
|
|
|
fields = results.whitelist;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.getObjectsFields(uidsToUserKeys(uniqueUids), fields, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (users, next) {
|
|
|
|
function (users, next) {
|
|
|
|
users = uidsToUsers(uids, uniqueUids, users);
|
|
|
|
users = uidsToUsers(uids, uniqueUids, users);
|
|
|
@ -118,14 +136,6 @@ module.exports = function (User) {
|
|
|
|
user.username = validator.escape(user.username ? user.username.toString() : '');
|
|
|
|
user.username = validator.escape(user.username ? user.username.toString() : '');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (user.password) {
|
|
|
|
|
|
|
|
user.password = undefined;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user.rss_token) {
|
|
|
|
|
|
|
|
user.rss_token = undefined;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!parseInt(user.uid, 10)) {
|
|
|
|
if (!parseInt(user.uid, 10)) {
|
|
|
|
user.uid = 0;
|
|
|
|
user.uid = 0;
|
|
|
|
user.username = '[[global:guest]]';
|
|
|
|
user.username = '[[global:guest]]';
|
|
|
|