From 3a2526c4c2d5b5c6afc577f0643925f39dbacd8e Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Mon, 2 Dec 2019 17:09:46 -0600 Subject: [PATCH] Fix https://github.com/parse-community/Parse-SDK-JS/issues/992 After much discussion the proper way to subclass is a user is `Parse.Object.registerSubclass('_User', CustomUser);` Revert #https://github.com/parse-community/Parse-SDK-JS/pull/978 --- integration/test/ParseUserTest.js | 2 ++ src/ParseUser.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/integration/test/ParseUserTest.js b/integration/test/ParseUserTest.js index 132fccb73..32e46ee85 100644 --- a/integration/test/ParseUserTest.js +++ b/integration/test/ParseUserTest.js @@ -49,6 +49,7 @@ describe('Parse User', () => { Parse.initialize('integration', null, 'notsosecret'); Parse.CoreManager.set('SERVER_URL', 'http://localhost:1337/parse'); Parse.Storage._clear(); + Parse.Object.registerSubclass('_User', Parse.User); }); beforeEach((done) => { @@ -632,6 +633,7 @@ describe('Parse User', () => { it('can get current with subclass', async () => { Parse.User.enableUnsafeCurrentUser(); + Parse.Object.registerSubclass('_User', CustomUser); const customUser = new CustomUser({ foo: 'bar' }); customUser.setUsername('username'); diff --git a/src/ParseUser.js b/src/ParseUser.js index c778afaa6..b50857132 100644 --- a/src/ParseUser.js +++ b/src/ParseUser.js @@ -871,7 +871,7 @@ const DefaultController = { const json = user.toJSON(); delete json.password; - json.className = user.constructor.name === ParseUser.name ? '_User' : user.constructor.name; + json.className = '_User'; return Storage.setItemAsync( path, JSON.stringify(json) ).then(() => {