v1.18.x
Julian Lam 11 years ago
parent 1052165373
commit 8557c56c45

@ -83,12 +83,12 @@
}); });
app.post('/login', function(req, res, next) { app.post('/login', function(req, res, next) {
passport.authenticate('local', function(err, user, info) { passport.authenticate('local', function(err, userData, info) {
if (err) { if (err) {
return next(err); return next(err);
} }
if (!user) { if (!userData) {
return res.json(403, info); return res.json(403, info);
} }
@ -103,9 +103,13 @@
} }
req.login({ req.login({
uid: user.uid uid: userData.uid
}, function() { }, function() {
res.json(info); if (userData.uid) {
user.logIP(userData.uid, req.ip);
}
res.json(200, info);
}); });
})(req, res, next); })(req, res, next);
}); });
@ -149,6 +153,7 @@
} }
if(!uid) { 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'); return next(null, false, 'user doesn\'t exist');
} }
@ -172,7 +177,7 @@
} }
if (!res) { if (!res) {
next(null, false, 'invalid-password'); return next(null, false, 'invalid-password');
} }
next(null, { 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 = { User.email = {
verify: function(uid, email) { verify: function(uid, email) {
if (!plugins.hasListeners('action:email.send')) { if (!plugins.hasListeners('action:email.send')) {

Loading…
Cancel
Save