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

Fix CartBlamerListener case with empty token #528

Closed
wants to merge 1 commit into from

Conversation

diimpp
Copy link
Member

@diimpp diimpp commented Sep 4, 2019

This PR solves false-positive CartBlamerListener execution.

$cart = $this->cartRepository->findOneBy(['tokenValue' => $token]);

If database contains orders without tokenValue, then it will return non-null $cart result for null $token. Order.orm.xml tokenValue is nullable

@diimpp diimpp requested a review from a team as a code owner September 4, 2019 14:02
Copy link
Member

@lchrusciel lchrusciel left a comment

Choose a reason for hiding this comment

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

Hello Dimitri,

thanks for the contribution :)

@@ -44,7 +44,9 @@ public function onJwtLogin(JWTCreatedEvent $interactiveLoginEvent): void
return;
}

$token = $request->request->get('token');
if (null === $token = $request->request->get('token')) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we leave token in a separate line?

Also, we miss test for this behavior. Can you add it to PickupApiTest file? Or introduce spec for this class? Or (in the best case) do both? :)

@lchrusciel lchrusciel added the Bug label Sep 9, 2019
@mamazu
Copy link
Member

mamazu commented Sep 9, 2019

One thing I would even recommend is using a CartProvider with token. This would also allow users to add more constraints and checks on it (eg. is cart in current channel and so on).

@lchrusciel
Copy link
Member

Thanks Dmitri for the contribution! Nevertheless, this issue will be solved by #536, as it contains a documentation as well

@lchrusciel lchrusciel closed this Sep 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants