From 12219019b8dce0b9578f1899368cd0d4cb283ed2 Mon Sep 17 00:00:00 2001 From: Marco129 Date: Fri, 13 May 2016 17:43:19 +0800 Subject: [PATCH] Fix error when unset user email --- spec/ParseUser.spec.js | 16 ++++++++++++++++ src/RestWrite.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index 0873f4426f8..42f48a4d725 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -1834,6 +1834,22 @@ describe('Parse.User testing', () => { }); }); + it('unset user email', (done) => { + var user = new Parse.User(); + user.set('username', 'test'); + user.set('password', 'test'); + user.set('email', 'test@test.com'); + user.signUp().then(() => { + user.unset('email'); + return user.save(); + }).then(() => { + done(); + }, (error) => { + fail('Should not fail'); + done(); + }); + }); + it('create session from user', (done) => { Parse.Promise.as().then(() => { return Parse.User.signUp("finn", "human", { foo: "bar" }); diff --git a/src/RestWrite.js b/src/RestWrite.js index 03138e44f41..ecb92a85e43 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -356,7 +356,7 @@ RestWrite.prototype.transformUser = function() { return Promise.resolve(); }); }).then(() => { - if (!this.data.email) { + if (!this.data.email || this.data.email.__op === 'Delete') { return; } // Validate basic email address format