Skip to content

Commit 3005a7b

Browse files
author
Arthur Cinader
committed
PR Comment fixes...
1 parent c03c357 commit 3005a7b

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/RestQuery.js

+19-13
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,30 @@ RestQuery.prototype.replaceDontSelect = function() {
387387
};
388388

389389
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)) {
391393
return;
392394
}
393395

394396
for (const field of config.userSensitiveFields) {
395397
delete result[field];
396398
}
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+
};
398414

399415
// Returns a promise for whether it was successful.
400416
// Populates this.response with an object that only has 'results'.
@@ -416,18 +432,8 @@ RestQuery.prototype.runFind = function(options = {}) {
416432
this.className, this.restWhere, findOptions).then((results) => {
417433
if (this.className === '_User') {
418434
for (var result of results) {
419-
delete result.password;
420435
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);
431437
}
432438
}
433439

0 commit comments

Comments
 (0)