Skip to content

Commit fc79703

Browse files
authored
Merge pull request #417 from acinader/remove-anon-authdata-when-register
Remove anon authdata when register
2 parents 7204282 + 9f8cc20 commit fc79703

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Parse/ParseUser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function getUsername()
5151
*/
5252
public function setUsername($username)
5353
{
54+
$this->set('authData.anonymous', null);
5455
return $this->set('username', $username);
5556
}
5657

tests/Parse/ParseUserTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,4 +759,15 @@ public function testRequestVerificationEmailBad()
759759
$this->setExpectedException('Parse\ParseException', 'No user found with email not_a_known_email');
760760
ParseUser::requestVerificationEmail('not_a_known_email');
761761
}
762+
763+
public function testRegisteringAnonymousClearsAuthData()
764+
{
765+
$user = ParseUser::loginWithAnonymous();
766+
$response = ParseClient::_request('GET', 'users', null, null, true);
767+
$this->assertNotNull($response['results'][0]['authData']['anonymous']);
768+
$user->setUsername('Mary');
769+
$user->save();
770+
$response = ParseClient::_request('GET', 'users', null, null, true);
771+
$this->assertArrayNotHasKey('authData', $response['results'][0]) ;
772+
}
762773
}

0 commit comments

Comments
 (0)