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 remote possibility to return wrong current order #183

Merged
merged 1 commit into from Sep 7, 2021

Conversation

waiting-for-dev
Copy link
Contributor

Orders' guest token is always populated thanks to a before_create
callback on the application
layer
.
However, it can be NULL in the database.

This commit makes sure that no order is returned in two situations:

  1. X-Spree-Order-Token is not given, and it exists an order with
    NULL guest token.
  2. X-Spree-Order-Token is provided as an empty string, and it exists
    an order with an empty string as a guest token.

Being defensive against these two options leaves us on the safe side if
business rules around the guest token change at some point in
solidus-core.

This problem is similar to what is fixed in #182

Orders' guest token is always populated thanks to a [`before_create`
callback on the application
layer](https://github.com/solidusio/solidus/blob/ea200dfcc03ed542ab130317ccab4f365c31af7e/core/app/models/spree/order.rb#L128).
However, it can be `NULL` in the database.

This commit makes sure that no order is returned in two situations:

1. `X-Spree-Order-Token` is not given, and it exists an order with
   `NULL` guest token.
2. `X-Spree-Order-Token` is provided as an empty string, and it exists
   an order with an empty string as a guest token.

Being defensive against these two options leaves us on the safe side if
business rules around the guest token change at some point in
solidus-core.

This problem is similar to what is fixed in #182
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/fix_order_impersonation branch from e411188 to cb73bf1 Compare September 7, 2021 10:07
@kennyadsl kennyadsl merged commit a35aa80 into master Sep 7, 2021
@kennyadsl kennyadsl deleted the waiting-for-dev/fix_order_impersonation branch September 7, 2021 10:19
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.

None yet

2 participants