File tree 2 files changed +32
-0
lines changed
2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -2257,6 +2257,27 @@ describe('Parse.User testing', () => {
2257
2257
} )
2258
2258
} ) ;
2259
2259
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
+
2260
2281
it_exclude_dbs ( [ 'postgres' ] ) ( 'should cleanup null authData keys ParseUser update (regression test for #1198, #2252)' , ( done ) => {
2261
2282
Parse . Cloud . beforeSave ( '_User' , ( req , res ) => {
2262
2283
req . object . set ( 'foo' , 'bar' ) ;
Original file line number Diff line number Diff line change @@ -394,6 +394,17 @@ RestQuery.prototype.runFind = function() {
394
394
if ( this . className === '_User' ) {
395
395
for ( var result of results ) {
396
396
delete result . password ;
397
+
398
+ if ( result . authData ) {
399
+ Object . keys ( result . authData ) . forEach ( ( provider ) => {
400
+ if ( result . authData [ provider ] === null ) {
401
+ delete result . authData [ provider ] ;
402
+ }
403
+ } ) ;
404
+ if ( Object . keys ( result . authData ) . length == 0 ) {
405
+ delete result . authData ;
406
+ }
407
+ }
397
408
}
398
409
}
399
410
You can’t perform that action at this time.
0 commit comments