Merge pull request #1291 from ParsePlatform/flovilmart.issue1257
Properly let masterKey add fields
This commit is contained in:
@@ -1496,4 +1496,20 @@ describe('schemas', () => {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can add field as master (issue #1257)', (done) => {
|
||||||
|
setPermissionsOnClass('AClass', {
|
||||||
|
'addField': {}
|
||||||
|
}).then(() => {
|
||||||
|
var obj = new Parse.Object('AClass');
|
||||||
|
obj.set('key', 'value');
|
||||||
|
return obj.save(null, {useMasterKey: true})
|
||||||
|
}).then((obj) => {
|
||||||
|
expect(obj.get('key')).toEqual('value');
|
||||||
|
done();
|
||||||
|
}, (err) => {
|
||||||
|
fail('should not fail');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -103,9 +103,14 @@ DatabaseController.prototype.redirectClassNameForKey = function(className, key)
|
|||||||
// batch request, that could confuse other users of the schema.
|
// batch request, that could confuse other users of the schema.
|
||||||
DatabaseController.prototype.validateObject = function(className, object, query, options) {
|
DatabaseController.prototype.validateObject = function(className, object, query, options) {
|
||||||
let schema;
|
let schema;
|
||||||
|
let isMaster = !('acl' in options);
|
||||||
|
var aclGroup = options.acl || [];
|
||||||
return this.loadSchema().then(s => {
|
return this.loadSchema().then(s => {
|
||||||
schema = s;
|
schema = s;
|
||||||
return this.canAddField(schema, className, object, options.acl || []);
|
if (isMaster) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return this.canAddField(schema, className, object, aclGroup);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return schema.validateObject(className, object, query);
|
return schema.validateObject(className, object, query);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user