Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed throwing an error with anonymous users #5

Merged

Conversation

patrickbussmann
Copy link

I now had the situation that I want to deliver a function to anonymous users.
And then I'm wondering why I always get this Token for event was null error - until I find out that the original repository returns nothing there while this symfony-5 implementation throws an exception.

So I added a test for anonymous users and fixed the problem.

If there is another sense for this throwing logic exception you can explain me how I can enable anonymous users - because the user is only anonymous when all authentications are returning null = AnonymousToken instead OAuthToken

@patrickbussmann
Copy link
Author

Now it work's: @elchris
FriendsOfSymfony#625

Here is the pull request.

@patrickbussmann
Copy link
Author

Can you merge this please? @elchris

@@ -67,7 +67,7 @@ public function __invoke(RequestEvent $event)
public function handle(RequestEvent $event): void
{
if (null === $oauthToken = $this->serverService->getBearerToken($event->getRequest(), true)) {
throw new LogicException('Token for event was null');
return;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to keep things clean, do you think that you could avoid having the "return" as the "handle" method's return type is "void" so it's technically not supposed to "return". It looks like when the token is null you just want to "do nothing", in which case you might be able to "invert the if" such that the new token gets created only of the oauthToken is not null.

@patrickbussmann what do you think?

And I really like that you made a test to capture this use-case. Thank you for this! :)

@elchris
Copy link
Owner

elchris commented Feb 24, 2020

Can you merge this please? @elchris

yes can you please look at this first?

@elchris elchris merged commit 092cea1 into elchris:symfony-5 Feb 24, 2020
@elchris
Copy link
Owner

elchris commented Feb 24, 2020

Can you merge this please? @elchris

yes can you please look at this first?

I merged it anyway

@patrickbussmann
Copy link
Author

Ah ok but yes I could change this. Sorry I didnt get the message 😣

@elchris
Copy link
Owner

elchris commented Feb 24, 2020

Ah ok but yes I could change this. Sorry I didnt get the message 😣

no worries, it looks like I'd forgotten to "submit the review", my bad hehe.

Can you pull from my fork again, because I merged other changes that touched the same file, and look at that method again and submit another PR with the fix if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants