Skip to content

Commit 6fb55da

Browse files
committed
Unlogged "me" query now returns null.
Until now, the unloggued query was actually returning a user whose name was "anon.". This originates from a weird behaviour of Symfony. "me" should return null if noone is logged. Note this is a potential breaking change for clients implementing the "me" query, but since no one complained about the current behaviour that makes no sense, I'll assume this feature is not used wildly yet. If this PR introduce breaking changes in your code, please notify me.
1 parent 3f85584 commit 6fb55da

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Controller/GraphQL/MeController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ public function me(): ?UserInterface
4141
$user = $token->getUser();
4242

4343
if (!$user instanceof UserInterface) {
44-
// getUser() can be an object with a toString or a string
45-
$userName = (string) $user;
46-
$user = new BasicUser($userName);
44+
// getUser() can be the "anon." string.
45+
return null;
4746
}
4847

4948
return $user;

Tests/FunctionalTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,7 @@ public function testMeQuery(): void
290290

291291
$this->assertSame([
292292
'data' => [
293-
'me' => [
294-
'userName' => 'anon.',
295-
'roles' => [],
296-
]
293+
'me' => null
297294
]
298295
], $result);
299296

0 commit comments

Comments
 (0)