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

Control if customer is the owner of the selected order in contact form #9126

Merged
merged 1 commit into from Jun 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions controllers/front/ContactController.php
Expand Up @@ -63,6 +63,14 @@ public function postProcess()

$id_order = (int)$this->getOrder();

/**
* Check if customer select his order.
*/
if (!empty($id_order)) {
$order = new Order($id_order);
Copy link
Member

Choose a reason for hiding this comment

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

What happens if the order doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Order information are empty. No error, and $order->id_customer will return null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I try with injecting 9999 maybe someone can try too :)

Copy link
Member

Choose a reason for hiding this comment

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

Ok then!

$id_order = (int) $order->id_customer === (int) $customer->id ? $id_order : 0;
Copy link
Member

Choose a reason for hiding this comment

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

Be aware that this:

(int) $order->id_customer === (int) $customer->id

Is basically equivalent to doing this:

$order->id_customer == $customer->id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even if I'm agree with you, I prefer cast to integer because it's an id =)

}

if (!((
($id_customer_thread = (int)Tools::getValue('id_customer_thread'))
&& (int)Db::getInstance()->getValue('
Expand Down