Skip to content

Commit 73a3db4

Browse files
flovilmartdrew-gross
authored andcommitted
Fixes #1444 (#1451)
1 parent 281568e commit 73a3db4

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

spec/ParseUser.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,29 @@ describe('Parse.User testing', () => {
15141514
});
15151515
});
15161516

1517+
it('should properly error when password is missing', (done) => {
1518+
var provider = getMockFacebookProvider();
1519+
Parse.User._registerAuthenticationProvider(provider);
1520+
Parse.User._logInWith("facebook", {
1521+
success: function(user) {
1522+
user.set('username', 'myUser');
1523+
user.set('email', '[email protected]');
1524+
user.save().then(() => {
1525+
return Parse.User.logOut();
1526+
}).then(() => {
1527+
return Parse.User.logIn('myUser', 'password');
1528+
}).then(() => {
1529+
fail('should not succeed');
1530+
done();
1531+
}, (err) => {
1532+
expect(err.code).toBe(Parse.Error.OBJECT_NOT_FOUND);
1533+
expect(err.message).toEqual('Invalid username/password.');
1534+
done();
1535+
})
1536+
}
1537+
});
1538+
});
1539+
15171540
it('should have authData in beforeSave and afterSave', (done) => {
15181541

15191542
Parse.Cloud.beforeSave('_User', (request, response) => {

src/password.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ function hash(password) {
1919
// hashed password.
2020
function compare(password, hashedPassword) {
2121
return new Promise(function(fulfill, reject) {
22+
// Cannot bcrypt compare when one is undefined
23+
if (!password || !hashedPassword) {
24+
return fulfill(false);
25+
}
2226
bcrypt.compare(password, hashedPassword, function(err, success) {
2327
if (err) {
2428
reject(err);

0 commit comments

Comments
 (0)