mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-17 05:50:25 +01:00
get ips if admin or self
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user