display ips to admins/users on profile

v1.18.x
Baris Soner Usakli 11 years ago
parent de3bc84fde
commit 1ba3acfd03

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

@ -108,6 +108,18 @@
</div> </div>
</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> </div>

@ -593,7 +593,7 @@ var fs = require('fs'),
user.getFollowStats(uid, next); user.getFollowStats(uid, next);
}, },
ips: function(next) { ips: function(next) {
user.getIPs(uid, next); user.getIPs(uid, 4, next);
} }
}, function(err, results) { }, function(err, results) {
if(err || !results.userData) { if(err || !results.userData) {

@ -968,8 +968,16 @@ var bcrypt = require('bcryptjs'),
db.sortedSetAdd('uid:' + uid + ':ip', +new Date(), ip || 'Unknown'); db.sortedSetAdd('uid:' + uid + ':ip', +new Date(), ip || 'Unknown');
}; };
User.getIPs = function(uid, callback) { User.getIPs = function(uid, end, callback) {
db.getSortedSetRevRange('uid:' + uid + ':ip', 0, 5, 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 = { User.email = {

Loading…
Cancel
Save