mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
get ips if admin or self
This commit is contained in:
@@ -105,7 +105,9 @@
|
|||||||
req.login({
|
req.login({
|
||||||
uid: userData.uid
|
uid: userData.uid
|
||||||
}, function() {
|
}, function() {
|
||||||
|
console.log('TESTING', userData.uid);
|
||||||
if (userData.uid) {
|
if (userData.uid) {
|
||||||
|
console.log('FAIL?', userData.uid);
|
||||||
user.logIP(userData.uid, req.ip);
|
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/:userslug/posts', isAllowed, getUserPosts);
|
||||||
app.get('/api/user/uid/:uid', isAllowed, getUserData);
|
app.get('/api/user/uid/:uid', isAllowed, getUserData);
|
||||||
app.get('/api/user/:userslug', isAllowed, getUserProfile);
|
app.get('/api/user/:userslug', isAllowed, getUserProfile);
|
||||||
|
|
||||||
app.get('/api/users', isAllowed, getOnlineUsers);
|
app.get('/api/users', isAllowed, getOnlineUsers);
|
||||||
app.get('/api/users/sort-posts', isAllowed, getUsersSortedByPosts);
|
app.get('/api/users/sort-posts', isAllowed, getUsersSortedByPosts);
|
||||||
app.get('/api/users/sort-reputation', isAllowed, getUsersSortedByReputation);
|
app.get('/api/users/sort-reputation', isAllowed, getUsersSortedByReputation);
|
||||||
@@ -590,6 +591,9 @@ var fs = require('fs'),
|
|||||||
},
|
},
|
||||||
followStats: function(next) {
|
followStats: function(next) {
|
||||||
user.getFollowStats(uid, next);
|
user.getFollowStats(uid, next);
|
||||||
|
},
|
||||||
|
ips: function(next) {
|
||||||
|
user.getIPs(uid, next);
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if(err || !results.userData) {
|
if(err || !results.userData) {
|
||||||
@@ -599,6 +603,7 @@ var fs = require('fs'),
|
|||||||
var userData = results.userData;
|
var userData = results.userData;
|
||||||
var userSettings = results.userSettings;
|
var userSettings = results.userSettings;
|
||||||
var isAdmin = results.isAdmin;
|
var isAdmin = results.isAdmin;
|
||||||
|
var self = parseInt(callerUID, 10) === parseInt(userData.uid, 10);
|
||||||
|
|
||||||
userData.joindate = utils.toISOString(userData.joindate);
|
userData.joindate = utils.toISOString(userData.joindate);
|
||||||
if(userData.lastonline) {
|
if(userData.lastonline) {
|
||||||
@@ -614,19 +619,23 @@ var fs = require('fs'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
function canSeeEmail() {
|
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 = "";
|
userData.email = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(callerUID, 10) === parseInt(userData.uid, 10) && !userSettings.showemail) {
|
if (self && !userSettings.showemail) {
|
||||||
userData.emailClass = "";
|
userData.emailClass = "";
|
||||||
} else {
|
} else {
|
||||||
userData.emailClass = "hide";
|
userData.emailClass = "hide";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isAdmin || self) {
|
||||||
|
userData.ips = results.ips;
|
||||||
|
}
|
||||||
|
|
||||||
userData.websiteName = userData.website.replace('http://', '').replace('https://', '');
|
userData.websiteName = userData.website.replace('http://', '').replace('https://', '');
|
||||||
userData.banned = parseInt(userData.banned, 10) === 1;
|
userData.banned = parseInt(userData.banned, 10) === 1;
|
||||||
userData.uid = userData.uid;
|
userData.uid = userData.uid;
|
||||||
|
|||||||
@@ -968,6 +968,10 @@ 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) {
|
||||||
|
db.getSortedSetRevRange('uid:' + uid + ':ip', 0, 5, callback);
|
||||||
|
};
|
||||||
|
|
||||||
User.email = {
|
User.email = {
|
||||||
verify: function(uid, email) {
|
verify: function(uid, email) {
|
||||||
if (!plugins.hasListeners('action:email.send')) {
|
if (!plugins.hasListeners('action:email.send')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user