v1.18.x
Julian Lam 12 years ago
parent b7498416fa
commit 4a18728e19

@ -14,14 +14,13 @@ var user = require('./user.js'),
message: 'invalid-user'
});
} else {
RDB.get('username:' + username + ':uid', function(err, uid) {
RDB.handle(err);
user.get_uid_by_username(username, function(err, uid) {
if (err) {
return next(new Error('redis-error'));
}
if (uid == null) {
return next({
status: 'error',
message: 'invalid-user'
});
return next(new Error('invalid-user'));
}
user.getUserFields(uid, ['password', 'banned'], function(err, userData) {
@ -37,25 +36,14 @@ var user = require('./user.js'),
bcrypt.compare(password, userData.password, function(err, res) {
if(err) {
winston.err(err.message);
next({
status: "error",
message: 'bcrypt compare error'
});
next(new Error('bcrypt compare error'));
return;
}
if (res) {
next({
status: "ok",
user: {
uid: uid
}
});
next(null, { user: { uid: uid } });
} else {
next({
status: 'error',
message: 'invalid-password'
});
next(new Error('invalid-password'));
}
});
});

@ -12,9 +12,9 @@
login_module = require('./../login.js');
passport.use(new passportLocal(function(user, password, next) {
login_module.loginViaLocal(user, password, function(login) {
if (login.status === 'ok') next(null, login.user);
else next(null, false, login);
login_module.loginViaLocal(user, password, function(err, login) {
if (!err) next(null, login.user);
else next(null, false, err);
});
}));

@ -628,12 +628,7 @@ var utils = require('./../public/src/utils.js'),
}
User.get_uid_by_username = function(username, callback) {
RDB.hget('username::uid', username, function(err, data) {
if (err) {
RDB.handle(err);
}
callback(data);
});
RDB.hget('username:uid', username, callback);
};
User.get_uid_by_userslug = function(userslug, callback) {

Loading…
Cancel
Save