Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 11 years ago
commit 815e78339f

@ -65,6 +65,7 @@
"in": "in",
"recentposts": "Recent Posts",
"recentips": "Recently Logged In IPs",
"online": "Online",
"away": "Away",

@ -108,6 +108,18 @@
</div>
</div>
<!-- IF ips.length -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">[[global:recentips]]</h3>
</div>
<div class="panel-body">
<!-- BEGIN ips -->
{ips.ip}
<!-- END ips -->
</div>
</div>
<!-- ENDIF ips.length -->
</div>

@ -230,6 +230,7 @@ var fs = require('fs'),
app.get('/api/user/:userslug/posts', isAllowed, getUserPosts);
app.get('/api/user/uid/:uid', isAllowed, getUserData);
app.get('/api/user/:userslug', isAllowed, getUserProfile);
app.get('/api/users', isAllowed, getOnlineUsers);
app.get('/api/users/sort-posts', isAllowed, getUsersSortedByPosts);
app.get('/api/users/sort-reputation', isAllowed, getUsersSortedByReputation);
@ -590,6 +591,9 @@ var fs = require('fs'),
},
followStats: function(next) {
user.getFollowStats(uid, next);
},
ips: function(next) {
user.getIPs(uid, 4, next);
}
}, function(err, results) {
if(err || !results.userData) {
@ -599,6 +603,7 @@ var fs = require('fs'),
var userData = results.userData;
var userSettings = results.userSettings;
var isAdmin = results.isAdmin;
var self = parseInt(callerUID, 10) === parseInt(userData.uid, 10);
userData.joindate = utils.toISOString(userData.joindate);
if(userData.lastonline) {
@ -614,19 +619,23 @@ var fs = require('fs'),
}
function canSeeEmail() {
return isAdmin || parseInt(callerUID, 10) === parseInt(userData.uid, 10) || (userData.email && userSettings.showemail);
return ;
}
if (!canSeeEmail()) {
if (!(isAdmin || self || (userData.email && userSettings.showemail))) {
userData.email = "";
}
if (parseInt(callerUID, 10) === parseInt(userData.uid, 10) && !userSettings.showemail) {
if (self && !userSettings.showemail) {
userData.emailClass = "";
} else {
userData.emailClass = "hide";
}
if (isAdmin || self) {
userData.ips = results.ips;
}
userData.websiteName = userData.website.replace('http://', '').replace('https://', '');
userData.banned = parseInt(userData.banned, 10) === 1;
userData.uid = userData.uid;

@ -968,6 +968,18 @@ var bcrypt = require('bcryptjs'),
db.sortedSetAdd('uid:' + uid + ':ip', +new Date(), ip || 'Unknown');
};
User.getIPs = function(uid, end, callback) {
db.getSortedSetRevRange('uid:' + uid + ':ip', 0, end, function(err, ips) {
if(err) {
return callback(err);
}
callback(null, ips.map(function(ip) {
return {ip:ip};
}));
});
};
User.email = {
verify: function(uid, email) {
if (!plugins.hasListeners('action:email.send')) {

Loading…
Cancel
Save