Fix login query
This commit is contained in:
parent
7f1e88e816
commit
423b4f2157
|
@ -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) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue