diff --git a/ExportAdapter.js b/ExportAdapter.js index db586d8348..5ba4f8e35e 100644 --- a/ExportAdapter.js +++ b/ExportAdapter.js @@ -124,9 +124,9 @@ ExportAdapter.prototype.redirectClassNameForKey = function(className, key) { // Returns a promise that resolves to the new schema. // This does not update this.schema, because in a situation like a // batch request, that could confuse other users of the schema. -ExportAdapter.prototype.validateObject = function(className, object) { +ExportAdapter.prototype.validateObject = function(className, object, freeze) { return this.loadSchema().then((schema) => { - return schema.validateObject(className, object); + return schema.validateObject(className, object, freeze); }); }; diff --git a/RestWrite.js b/RestWrite.js index ea7b2225e2..e6cf519f9a 100644 --- a/RestWrite.js +++ b/RestWrite.js @@ -91,7 +91,8 @@ RestWrite.prototype.execute = function() { // Validates this operation against the schema. RestWrite.prototype.validateSchema = function() { - return this.config.database.validateObject(this.className, this.data); + var schemaFrozen = (process.env.NODE_ENV !== 'development') ? !(this.auth && this.auth.isMaster) : false; + return this.config.database.validateObject(this.className, this.data, schemaFrozen); }; // Runs any beforeSave triggers against this operation. diff --git a/Schema.js b/Schema.js index c95444045e..8b6accc5ce 100644 --- a/Schema.js +++ b/Schema.js @@ -199,18 +199,18 @@ Schema.prototype.validateField = function(className, key, type, freeze) { // Given a schema promise, construct another schema promise that // validates this field once the schema loads. -function thenValidateField(schemaPromise, className, key, type) { +function thenValidateField(schemaPromise, className, key, type, freeze) { return schemaPromise.then((schema) => { - return schema.validateField(className, key, type); + return schema.validateField(className, key, type, freeze); }); } // Validates an object provided in REST format. // Returns a promise that resolves to the new schema if this object is // valid. -Schema.prototype.validateObject = function(className, object) { +Schema.prototype.validateObject = function(className, object, freeze) { var geocount = 0; - var promise = this.validateClassName(className); + var promise = this.validateClassName(className, freeze); for (var key in object) { var expected = getType(object[key]); if (expected === 'geopoint') { @@ -224,7 +224,7 @@ Schema.prototype.validateObject = function(className, object) { if (!expected) { continue; } - promise = thenValidateField(promise, className, key, expected); + promise = thenValidateField(promise, className, key, expected, freeze); } return promise; }; diff --git a/functions.js b/functions.js index ee2ac54125..933da4c823 100644 --- a/functions.js +++ b/functions.js @@ -13,7 +13,13 @@ function handleCloudFunction(req) { var response = createResponseObject(resolve, reject); var request = { params: req.body || {}, +<<<<<<< HEAD + master : req.auth ? req.auth.isMaster : false, + user : req.auth && req.auth.user ? req.auth.user : undefined, + installationId : req.auth && req.auth.installationId ? req.auth.installationId : undefined +======= user: req.auth && req.auth.user || {} +>>>>>>> upstream/master }; Parse.Cloud.Functions[req.params.functionName](request, response); }); @@ -34,10 +40,10 @@ function createResponseObject(resolve, reject) { error: function(error) { reject(new Parse.Error(Parse.Error.SCRIPT_FAILED, error)); } - } + }; } -router.route('POST', '/functions/:functionName', handleCloudFunction); +router.route('POST', '/functions/:functionName+', handleCloudFunction); module.exports = router;