mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 06:07:28 +02:00
Merge branch 'master' of https://github.com/designcreateplay/NodeBB
This commit is contained in:
@@ -83,12 +83,12 @@
|
||||
});
|
||||
|
||||
app.post('/login', function(req, res, next) {
|
||||
passport.authenticate('local', function(err, user, info) {
|
||||
passport.authenticate('local', function(err, userData, info) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
if (!userData) {
|
||||
return res.json(403, info);
|
||||
}
|
||||
|
||||
@@ -103,9 +103,13 @@
|
||||
}
|
||||
|
||||
req.login({
|
||||
uid: user.uid
|
||||
uid: userData.uid
|
||||
}, function() {
|
||||
res.json(info);
|
||||
if (userData.uid) {
|
||||
user.logIP(userData.uid, req.ip);
|
||||
}
|
||||
|
||||
res.json(200, info);
|
||||
});
|
||||
})(req, res, next);
|
||||
});
|
||||
@@ -149,6 +153,7 @@
|
||||
}
|
||||
|
||||
if(!uid) {
|
||||
// Even if a user doesn't exist, compare passwords anyway, so we don't immediately return
|
||||
return next(null, false, 'user doesn\'t exist');
|
||||
}
|
||||
|
||||
@@ -172,7 +177,7 @@
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
next(null, false, 'invalid-password');
|
||||
return next(null, false, 'invalid-password');
|
||||
}
|
||||
|
||||
next(null, {
|
||||
|
||||
@@ -963,6 +963,12 @@ var bcrypt = require('bcryptjs'),
|
||||
});
|
||||
};
|
||||
|
||||
User.logIP = function(uid, ip) {
|
||||
db.sortedSetAdd('uid:' + uid + ':ip', +new Date(), ip || 'Unknown', function(err) {
|
||||
console.log(ip, 'for uid', uid);
|
||||
});
|
||||
};
|
||||
|
||||
User.email = {
|
||||
verify: function(uid, email) {
|
||||
if (!plugins.hasListeners('action:email.send')) {
|
||||
|
||||
Reference in New Issue
Block a user