From 78cd6cdf639884d19ac75c0c770e6baa7029d2a5 Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Wed, 24 Feb 2016 11:41:22 +0100 Subject: [PATCH] Validates authData before (instead of after) calling the beforeSave trigger --- src/RestWrite.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/RestWrite.js b/src/RestWrite.js index bc2b91bac8..b1700fe8dd 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -65,12 +65,12 @@ RestWrite.prototype.execute = function() { return this.handleInstallation(); }).then(() => { return this.handleSession(); + }).then(() => { + return this.validateAuthData(); }).then(() => { return this.runBeforeTrigger(); }).then(() => { return this.setRequiredFieldsIfNeeded(); - }).then(() => { - return this.validateAuthData(); }).then(() => { return this.transformUser(); }).then(() => { @@ -111,6 +111,10 @@ RestWrite.prototype.validateSchema = function() { // Runs any beforeSave triggers against this operation. // Any change leads to our data being mutated. RestWrite.prototype.runBeforeTrigger = function() { + if (this.response) { + return; + } + // Cloud code gets a bit of extra data for its objects var extraData = {className: this.className}; if (this.query && this.query.objectId) {