From 4884f8cbf745e0c22058ccdb4e20b9892c6adabc Mon Sep 17 00:00:00 2001 From: Arthur Cinader <700572+acinader@users.noreply.github.com> Date: Tue, 2 Oct 2018 14:17:02 -0700 Subject: [PATCH 1/2] add a filing test this replicates https://github.com/parse-community/Parse-SDK-JS/blob/master/src/__tests__/ParseUser-test.js#L675 --- tests/Parse/ParseUserTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Parse/ParseUserTest.php b/tests/Parse/ParseUserTest.php index 1f101d24..6be0a1c3 100644 --- a/tests/Parse/ParseUserTest.php +++ b/tests/Parse/ParseUserTest.php @@ -759,4 +759,15 @@ public function testRequestVerificationEmailBad() $this->setExpectedException('Parse\ParseException', 'No user found with email not_a_known_email'); ParseUser::requestVerificationEmail('not_a_known_email'); } + + public function testRegisteringAnonymousClearsAuthData() + { + $user = ParseUser::loginWithAnonymous(); + $response = ParseClient::_request('GET', 'users', null, null, true); + $this->assertNotNull($response['results'][0]['authData']['anonymous']); + $user->setUsername('Mary'); + $user->save(); + $response = ParseClient::_request('GET', 'users', null, null, true); + $this->assertArrayNotHasKey('authData', $response['results'][0]) ; + } } From 9f8cc2022b5242e445d26d77014c4a17cb2cffe4 Mon Sep 17 00:00:00 2001 From: Arthur Cinader <700572+acinader@users.noreply.github.com> Date: Tue, 2 Oct 2018 14:17:35 -0700 Subject: [PATCH 2/2] strip auth data when setting username --- src/Parse/ParseUser.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Parse/ParseUser.php b/src/Parse/ParseUser.php index e559b176..e6410f31 100644 --- a/src/Parse/ParseUser.php +++ b/src/Parse/ParseUser.php @@ -51,6 +51,7 @@ public function getUsername() */ public function setUsername($username) { + $this->set('authData.anonymous', null); return $this->set('username', $username); }