get ips if admin or self

v1.18.x
Baris Soner Usakli 11 years ago
parent f5d1ba4231
commit cc8ac2c026

@ -105,7 +105,9 @@
req.login({
uid: userData.uid
}, function() {
console.log('TESTING', userData.uid);
if (userData.uid) {
console.log('FAIL?', userData.uid);
user.logIP(userData.uid, req.ip);
}

@ -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, 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,10 @@ var bcrypt = require('bcryptjs'),
db.sortedSetAdd('uid:' + uid + ':ip', +new Date(), ip || 'Unknown');
};
User.getIPs = function(uid, callback) {
db.getSortedSetRevRange('uid:' + uid + ':ip', 0, 5, callback);
};
User.email = {
verify: function(uid, email) {
if (!plugins.hasListeners('action:email.send')) {

Loading…
Cancel
Save