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); } 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]) ; + } }