From b7d2f88542e410b4fc547211d3ba32f214167a25 Mon Sep 17 00:00:00 2001 From: Drew Gross Date: Thu, 14 Apr 2016 15:54:17 -0700 Subject: [PATCH] Notes --- spec/ParseUser.spec.js | 23 +++++++++++++++++++++++ src/RestWrite.js | 2 ++ 2 files changed, 25 insertions(+) diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index 0873f4426f..00937e2bbc 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -2407,4 +2407,27 @@ describe('Parse.User testing', () => { }) }); }) + + it('should not allow you to sign up with facebook twice (regression test for #1488)', done => { + const signUpPromise1 = Parse.FacebookUtils.logIn({ + id: "8675309", + access_token: "jenny", + expiration_date: new Date().toJSON() + }).;st signUpPromise2 = Parse.FacebookUtils.logIn({ + id: "8675309", + access_token: "jenny", + expiration_date: new Date().toJSON() + }); + Promise.all([signUpPromise1, signUpPromise2]).then(() => { + new Parse.Query(Parse.User) + .find({ useMasterKey: true }) + .then(allUsers => { + expect(allUsers.length).toEqual(1); + done(); + }); + }, e => { + console.log(e); + done(); + }) + }); }); diff --git a/src/RestWrite.js b/src/RestWrite.js index 03138e44f4..033d8102d8 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -338,6 +338,8 @@ RestWrite.prototype.transformUser = function() { }).then(() => { // Check for username uniqueness + //TODO: use a unique index on usernames to check for uniqueness to avoid race conditions + //TODO: use a unique index on auth data to fix issue #1488 if (!this.data.username) { if (!this.query) { this.data.username = cryptoUtils.randomString(25);