From 6cafd46d06d1663837a0459c2e01bd7d443de1f7 Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Sat, 27 Feb 2016 15:54:43 +0100 Subject: [PATCH] Validate authData before triggering beforeSave --- src/RestWrite.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/RestWrite.js b/src/RestWrite.js index 4922f71d..3e1c2f6a 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -67,12 +67,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(() => { @@ -134,6 +134,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; + } + // Avoid doing any setup for triggers if there is no 'beforeSave' trigger for this class. if (!triggers.triggerExists(this.className, triggers.Types.beforeSave, this.config.applicationId)) { return Promise.resolve();