Skip to content

Commit 008479a

Browse files
authored
Merge pull request #78 from kesslerdev/fix/no-authenticated-token
Fix Error when using a no authenticated token
2 parents 8123aff + fe3f850 commit 008479a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/EventListener/ExceptionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function onKernelRequest(GetResponseEvent $event)
8383

8484
$token = $this->tokenStorage->getToken();
8585

86-
if (null !== $token && $this->authorizationChecker->isGranted(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED)) {
86+
if (null !== $token && $token->isAuthenticated() && $this->authorizationChecker->isGranted(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED)) {
8787
$this->setUserValue($token->getUser());
8888

8989
$contextEvent = new SentryUserContextEvent($token);

test/EventListener/ExceptionListenerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ public function test_that_username_is_set_from_user_interface_if_token_present_a
260260
->willReturn($user)
261261
;
262262

263+
$mockToken
264+
->method('isAuthenticated')
265+
->willReturn(true)
266+
;
267+
263268
$mockEvent = $this->createMock(GetResponseEvent::class);
264269

265270
$mockEvent
@@ -311,6 +316,11 @@ public function test_that_username_is_set_from_user_interface_if_token_present_a
311316
->willReturn('some_user')
312317
;
313318

319+
$mockToken
320+
->method('isAuthenticated')
321+
->willReturn(true)
322+
;
323+
314324
$mockEvent = $this->createMock(GetResponseEvent::class);
315325

316326
$mockEvent
@@ -370,6 +380,11 @@ public function test_that_username_is_set_from_user_interface_if_token_present_a
370380
->willReturn($mockUser)
371381
;
372382

383+
$mockToken
384+
->method('isAuthenticated')
385+
->willReturn(true)
386+
;
387+
373388
$mockEvent = $this->createMock(GetResponseEvent::class);
374389

375390
$mockEvent

0 commit comments

Comments
 (0)