Skip to content

Commit

Permalink
Do not require addField permissions unless the root field does not exist
Browse files Browse the repository at this point in the history
Also added a corresponding regression test
  • Loading branch information
mstniy committed Apr 25, 2021
1 parent 3638b0e commit ed6a5d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions spec/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,24 @@ describe('SchemaController', () => {
});
});

describe('Class Level Permissions', () => {
it('does not require addField for nested modification (#7371)', async () => {
const testSchema = new Parse.Schema('test_7371');
testSchema.setCLP({
create: { ['*']: true },
update: { ['*']: true },
addField: {},
});
testSchema.addObject('a');
await testSchema.save();
const obj = new Parse.Object('test_7371');
obj.set('a', { b: 1 });
await obj.save();
obj.set('a.b', 2);
await obj.save();
});
});

describe('Class Level Permissions for requiredAuth', () => {
beforeEach(() => {
config = Config.get('test');
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/DatabaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ class DatabaseController {
if (object[field] && object[field].__op && object[field].__op === 'Delete') {
return false;
}
return schemaFields.indexOf(field) < 0;
return schemaFields.indexOf(getRootFieldName(field)) < 0;
});
if (newKeys.length > 0) {
// adds a marker that new field is being adding during update
Expand Down

0 comments on commit ed6a5d8

Please sign in to comment.