-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fixed throwing an error with anonymous users #5
Conversation
Now it work's: @elchris Here is the pull request. |
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; | |||
} |
There was a problem hiding this comment.
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! :)
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 |
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