mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
closes #4930
This commit is contained in:
@@ -1,22 +1,30 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
_ = require('underscore'),
|
var _ = require('underscore');
|
||||||
|
|
||||||
user = require('../../user'),
|
var user = require('../../user');
|
||||||
helpers = require('../helpers'),
|
var helpers = require('../helpers');
|
||||||
accountHelpers = require('./helpers');
|
var accountHelpers = require('./helpers');
|
||||||
|
|
||||||
var infoController = {};
|
var infoController = {};
|
||||||
|
|
||||||
infoController.get = function(req, res, next) {
|
infoController.get = function(req, res, next) {
|
||||||
accountHelpers.getBaseUser(req.params.userslug, req.uid, function(err, userData) {
|
accountHelpers.getBaseUser(req.params.userslug, req.uid, function(err, userData) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
ips: async.apply(user.getIPs, res.locals.uid, 4),
|
ips: async.apply(user.getIPs, res.locals.uid, 4),
|
||||||
history: async.apply(user.getModerationHistory, res.locals.uid),
|
history: async.apply(user.getModerationHistory, res.locals.uid),
|
||||||
fields: async.apply(user.getUserFields, res.locals.uid, ['banned'])
|
fields: async.apply(user.getUserFields, res.locals.uid, ['banned'])
|
||||||
}, function(err, data) {
|
}, function(err, data) {
|
||||||
data = _.extend(userData, {
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
userData = _.extend(userData, {
|
||||||
ips: data.ips,
|
ips: data.ips,
|
||||||
history: data.history
|
history: data.history
|
||||||
}, data.fields);
|
}, data.fields);
|
||||||
@@ -24,7 +32,7 @@ infoController.get = function(req, res, next) {
|
|||||||
userData.title = '[[pages:account/info]]';
|
userData.title = '[[pages:account/info]]';
|
||||||
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:settings]]'}]);
|
userData.breadcrumbs = helpers.buildBreadcrumbs([{text: userData.username, url: '/user/' + userData.userslug}, {text: '[[user:settings]]'}]);
|
||||||
|
|
||||||
res.render('account/info', data);
|
res.render('account/info', userData);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,14 +58,15 @@ module.exports = function(User) {
|
|||||||
if (fields.indexOf('banned') !== -1) {
|
if (fields.indexOf('banned') !== -1) {
|
||||||
// Also retrieve ban expiry for these users
|
// Also retrieve ban expiry for these users
|
||||||
db.sortedSetScores('users:banned:expire', uids, function(err, scores) {
|
db.sortedSetScores('users:banned:expire', uids, function(err, scores) {
|
||||||
users = users.map(function(userObj, idx) {
|
users.forEach(function(userObj, idx) {
|
||||||
userObj.banned_until = scores[idx] || 0;
|
userObj.banned_until = scores[idx] || 0;
|
||||||
userObj.banned_until_readable = scores[idx] ? new Date(scores[idx]).toString() : 'Not Banned';
|
userObj.banned_until_readable = scores[idx] ? new Date(scores[idx]).toString() : 'Not Banned';
|
||||||
});
|
});
|
||||||
|
modifyUserData(users, fieldsToRemove, callback);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
modifyUserData(users, fieldsToRemove, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
modifyUserData(users, fieldsToRemove, callback);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -104,7 +105,9 @@ module.exports = function(User) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.username = validator.escape(user.username ? user.username.toString() : '');
|
if (user.hasOwnProperty('username')) {
|
||||||
|
user.username = validator.escape(user.username ? user.username.toString() : '');
|
||||||
|
}
|
||||||
|
|
||||||
if (user.password) {
|
if (user.password) {
|
||||||
user.password = undefined;
|
user.password = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user