|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|