Ensure legacy users with authData are not locked out (#4898)
* Adds fix for issue, ensuring legacy users with no ACL are properly handled * Runs tests only on mongo
This commit is contained in:
@@ -427,7 +427,7 @@ class DatabaseController {
|
||||
}
|
||||
});
|
||||
for (const updateOperation in update) {
|
||||
if (Object.keys(updateOperation).some(innerKey => innerKey.includes('$') || innerKey.includes('.'))) {
|
||||
if (update[updateOperation] && typeof update[updateOperation] === 'object' && Object.keys(update[updateOperation]).some(innerKey => innerKey.includes('$') || innerKey.includes('.'))) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_NESTED_KEY, "Nested keys should not contain the '$' or '.' characters");
|
||||
}
|
||||
}
|
||||
@@ -660,7 +660,7 @@ class DatabaseController {
|
||||
* @param {boolean} fast set to true if it's ok to just delete rows and not indexes
|
||||
* @returns {Promise<void>} when the deletions completes
|
||||
*/
|
||||
deleteEverything(fast: boolean = false): Promise<void> {
|
||||
deleteEverything(fast: boolean = false): Promise<any> {
|
||||
this.schemaPromise = null;
|
||||
return Promise.all([
|
||||
this.adapter.deleteAllClasses(fast),
|
||||
|
||||
@@ -278,13 +278,23 @@ RestWrite.prototype.findUsersWithAuthData = function(authData) {
|
||||
return findPromise;
|
||||
}
|
||||
|
||||
RestWrite.prototype.filteredObjectsByACL = function(objects) {
|
||||
if (this.auth.isMaster) {
|
||||
return objects;
|
||||
}
|
||||
return objects.filter((object) => {
|
||||
if (!object.ACL) {
|
||||
return true; // legacy users that have no ACL field on them
|
||||
}
|
||||
// Regular users that have been locked out.
|
||||
return object.ACL && Object.keys(object.ACL).length > 0;
|
||||
});
|
||||
}
|
||||
|
||||
RestWrite.prototype.handleAuthData = function(authData) {
|
||||
let results;
|
||||
return this.findUsersWithAuthData(authData).then((r) => {
|
||||
results = r.filter((user) => {
|
||||
return !this.auth.isMaster && user.ACL && Object.keys(user.ACL).length > 0;
|
||||
});
|
||||
results = this.filteredObjectsByACL(r);
|
||||
if (results.length > 1) {
|
||||
// More than 1 user with the passed id's
|
||||
throw new Parse.Error(Parse.Error.ACCOUNT_ALREADY_LINKED,
|
||||
|
||||
Reference in New Issue
Block a user