Fix login query

This commit is contained in:
Ritchie Martori 2013-07-28 14:33:13 -07:00
parent 7f1e88e816
commit 423b4f2157
2 changed files with 11 additions and 1 deletions

View File

@ -69,7 +69,7 @@ User.login = function (credentials, fn) {
return fn(new Error('must provide username or email'));
}
this.findOne(query, function(err, user) {
this.findOne({where: query}, function(err, user) {
var defaultError = new Error('login failed');
if(err) {

View File

@ -121,6 +121,16 @@ describe('User', function(){
done();
});
});
it('Login should only allow correct credentials', function(done) {
User.create({email: 'foo22@bar.com', password: 'bar'}, function(user, err) {
User.login({email: 'foo44@bar.com', password: 'bar'}, function(err, session) {
assert(err);
assert(!session);
done();
});
});
});
});
describe('User.logout', function() {