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

stop contact form process if there's an error in the controller #78

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions contactform.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,26 +406,20 @@ public function sendMessage()
[],
'Shop.Notifications.Error'
);

return;
}
if (empty($message)) {
$this->context->controller->errors[] = $this->trans(
'The message cannot be blank.',
[],
'Shop.Notifications.Error'
);

return;
}
if (!Validate::isCleanHtml($message)) {
$this->context->controller->errors[] = $this->trans(
'Invalid message',
[],
'Shop.Notifications.Error'
);

return;
}

$id_contact = (int) Tools::getValue('id_contact');
Expand All @@ -437,8 +431,6 @@ public function sendMessage()
[],
'Modules.Contactform.Shop'
);

return;
}

if (!empty($file_attachment['name']) && $file_attachment['error'] != 0) {
Expand All @@ -447,8 +439,6 @@ public function sendMessage()
[],
'Modules.Contactform.Shop'
);

return;
}
if (!empty($file_attachment['name']) &&
!in_array(Tools::strtolower(Tools::substr($file_attachment['name'], -4)), $extension) &&
Expand All @@ -459,8 +449,6 @@ public function sendMessage()
[],
'Modules.Contactform.Shop'
);

return;
}
if ($url !== ''
|| empty($serverToken)
Expand All @@ -473,7 +461,9 @@ public function sendMessage()
'Modules.Contactform.Shop'
);
$this->createNewToken();
}

if (!empty($this->context->controller->errors)) {
return;
}

Expand Down
Loading