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