Skip to content

Commit

Permalink
Fixes #1444 (#1451)
Browse files Browse the repository at this point in the history
  • Loading branch information
flovilmart authored and drew-gross committed Apr 11, 2016
1 parent 281568e commit 73a3db4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,29 @@ describe('Parse.User testing', () => {
});
});

it('should properly error when password is missing', (done) => {
var provider = getMockFacebookProvider();
Parse.User._registerAuthenticationProvider(provider);
Parse.User._logInWith("facebook", {
success: function(user) {
user.set('username', 'myUser');
user.set('email', '[email protected]');
user.save().then(() => {
return Parse.User.logOut();
}).then(() => {
return Parse.User.logIn('myUser', 'password');
}).then(() => {
fail('should not succeed');
done();
}, (err) => {
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
expect(err.message).toEqual('Invalid username/password.');
done();
})
}
});
});

it('should have authData in beforeSave and afterSave', (done) => {

Parse.Cloud.beforeSave('_User', (request, response) => {
Expand Down
4 changes: 4 additions & 0 deletions src/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function hash(password) {
// hashed password.
function compare(password, hashedPassword) {
return new Promise(function(fulfill, reject) {
// Cannot bcrypt compare when one is undefined
if (!password || !hashedPassword) {
return fulfill(false);
}
bcrypt.compare(password, hashedPassword, function(err, success) {
if (err) {
reject(err);
Expand Down

0 comments on commit 73a3db4

Please sign in to comment.