@@ -387,14 +387,30 @@ RestQuery.prototype.replaceDontSelect = function() {
387
387
} ;
388
388
389
389
const cleanResultOfSensitiveUserInfo = function ( result , auth , config ) {
390
- if ( auth . isMaster || ( auth . user && auth . user . id === result . objectId ) ) {
390
+ delete result . password ;
391
+
392
+ if ( auth . isMaster || ( auth . user && auth . user . id === result . objectId ) ) {
391
393
return ;
392
394
}
393
395
394
396
for ( const field of config . userSensitiveFields ) {
395
397
delete result [ field ] ;
396
398
}
397
- }
399
+ } ;
400
+
401
+ const cleanResultAuthData = function ( result ) {
402
+ if ( result . authData ) {
403
+ Object . keys ( result . authData ) . forEach ( ( provider ) => {
404
+ if ( result . authData [ provider ] === null ) {
405
+ delete result . authData [ provider ] ;
406
+ }
407
+ } ) ;
408
+
409
+ if ( Object . keys ( result . authData ) . length == 0 ) {
410
+ delete result . authData ;
411
+ }
412
+ }
413
+ } ;
398
414
399
415
// Returns a promise for whether it was successful.
400
416
// Populates this.response with an object that only has 'results'.
@@ -416,18 +432,8 @@ RestQuery.prototype.runFind = function(options = {}) {
416
432
this . className , this . restWhere , findOptions ) . then ( ( results ) => {
417
433
if ( this . className === '_User' ) {
418
434
for ( var result of results ) {
419
- delete result . password ;
420
435
cleanResultOfSensitiveUserInfo ( result , this . auth , this . config ) ;
421
- if ( result . authData ) {
422
- Object . keys ( result . authData ) . forEach ( ( provider ) => {
423
- if ( result . authData [ provider ] === null ) {
424
- delete result . authData [ provider ] ;
425
- }
426
- } ) ;
427
- if ( Object . keys ( result . authData ) . length == 0 ) {
428
- delete result . authData ;
429
- }
430
- }
436
+ cleanResultAuthData ( result ) ;
431
437
}
432
438
}
433
439
0 commit comments