Skip to content

Commit c3bc118

Browse files
committed
parse-community#2.2.16 w/ cherry-pick
c81f48a
1 parent 9658d21 commit c3bc118

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

spec/ParseUser.spec.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,28 @@ describe('Parse.User testing', () => {
22572257
})
22582258
});
22592259

2260-
it('should cleanup null authData keys ParseUser update (regression test for #1198)', (done) => {
2260+
it_exclude_dbs(['postgres'])('should not serve null authData keys', (done) => {
2261+
let database = new Config(Parse.applicationId).database;
2262+
database.create('_User', {
2263+
username: 'user',
2264+
_hashed_password: '$2a$10$8/wZJyEuiEaobBBqzTG.jeY.XSFJd0rzaN//ososvEI4yLqI.4aie',
2265+
_auth_data_facebook: null
2266+
}, {}).then(() => {
2267+
return new Parse.Query(Parse.User)
2268+
.equalTo('username', 'user')
2269+
.first({useMasterKey: true});
2270+
}).then((user) => {
2271+
let authData = user.get('authData');
2272+
expect(user.get('username')).toEqual('user');
2273+
expect(authData).toBeUndefined();
2274+
done();
2275+
}).catch((err) => {
2276+
fail('this should not fail');
2277+
done();
2278+
})
2279+
});
2280+
2281+
it_exclude_dbs(['postgres'])('should cleanup null authData keys ParseUser update (regression test for #1198, #2252)', (done) => {
22612282
Parse.Cloud.beforeSave('_User', (req, res) => {
22622283
req.object.set('foo', 'bar');
22632284
res.success();

src/RestQuery.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@ RestQuery.prototype.runFind = function() {
393393
if (this.className === '_User') {
394394
for (var result of results) {
395395
delete result.password;
396+
397+
if (result.authData) {
398+
Object.keys(result.authData).forEach((provider) => {
399+
if (result.authData[provider] === null) {
400+
delete result.authData[provider];
401+
}
402+
});
403+
if (Object.keys(result.authData).length == 0) {
404+
delete result.authData;
405+
}
406+
}
396407
}
397408
}
398409

0 commit comments

Comments
 (0)