From de49de3c568a49fbe740277ae3c3908d4d316c76 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 22 Aug 2016 14:42:49 -0500 Subject: [PATCH] Show accounts using the same IP address as a registration queue entry (#4965) --- src/user/approval.js | 56 ++++++++++++++++--------- src/views/admin/manage/registration.tpl | 9 ++++ 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/user/approval.js b/src/user/approval.js index 8ccd5192aa..95b2daa68b 100644 --- a/src/user/approval.js +++ b/src/user/approval.js @@ -166,26 +166,44 @@ module.exports = function(User) { // temporary: see http://www.stopforumspam.com/forum/viewtopic.php?id=6392 user.ip = user.ip.replace('::ffff:', ''); - request({ - method: 'get', - url: 'http://api.stopforumspam.org/api' + - '?ip=' + encodeURIComponent(user.ip) + - '&email=' + encodeURIComponent(user.email) + - '&username=' + encodeURIComponent(user.username) + - '&f=json', - json: true - }, function (err, response, body) { - if (err) { - return next(null, user); + async.parallel([ + function(next) { + User.getUidsFromSet('ip:' + user.ip + ':uid', 0, -1, function(err, uids) { + if (err) { + return next(err); + } + + User.getUsersFields(uids, ['uid', 'username', 'picture'], function(err, ipMatch) { + user.ipMatch = ipMatch; + next(err); + }); + }); + }, + function(next) { + request({ + method: 'get', + url: 'http://api.stopforumspam.org/api' + + '?ip=' + encodeURIComponent(user.ip) + + '&email=' + encodeURIComponent(user.email) + + '&username=' + encodeURIComponent(user.username) + + '&f=json', + json: true + }, function (err, response, body) { + if (err) { + return next(); + } + if (response.statusCode === 200 && body) { + user.spamData = body; + user.usernameSpam = body.username ? (body.username.frequency > 0 || body.username.appears > 0) : true; + user.emailSpam = body.email ? (body.email.frequency > 0 || body.email.appears > 0) : true; + user.ipSpam = body.ip ? (body.ip.frequency > 0 || body.ip.appears > 0) : true; + } + + next(); + }); } - if (response.statusCode === 200 && body) { - user.spamData = body; - user.usernameSpam = body.username ? (body.username.frequency > 0 || body.username.appears > 0) : true; - user.emailSpam = body.email ? (body.email.frequency > 0 || body.email.appears > 0) : true; - user.ipSpam = body.ip ? (body.ip.frequency > 0 || body.ip.appears > 0) : true; - } - - next(null, user); + ], function(err) { + next(err, user); }); }, next); } diff --git a/src/views/admin/manage/registration.tpl b/src/views/admin/manage/registration.tpl index f751eca74d..5944219794 100644 --- a/src/views/admin/manage/registration.tpl +++ b/src/views/admin/manage/registration.tpl @@ -42,6 +42,15 @@ {users.ip} + +
+ + + +
{users.ipMatch.icon:text}
+ + {users.ipMatch.username} +