Skip to content

Commit

Permalink
Merge pull request #78 from aeyoll/fix-stop-execution-on-error
Browse files Browse the repository at this point in the history
stop contact form process if there's an error in the controller
  • Loading branch information
nicosomb committed Jul 4, 2024
2 parents 15587b7 + f922f40 commit 98f4722
Showing 1 changed file with 2 additions and 12 deletions.
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

0 comments on commit 98f4722

Please sign in to comment.