diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index d396fc8ca..424469876 100644 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -204,7 +204,10 @@ abstract class BaseController extends ContainerAware if ($aBaseForm instanceof FirewallForm && !$aBaseForm->isFirewallOk()) { throw new FormValidationException( $this->getTranslator()->trans( - "You have too much sent this form. Please wait before trying again." + "You've submitted this form too many times. Further submissions will be ignored during %time", + [ + "%time" => $aBaseForm->getWaitingTime(), + ] ) ); } diff --git a/core/lib/Thelia/Form/FirewallForm.php b/core/lib/Thelia/Form/FirewallForm.php index dc37d014f..1c793f21e 100644 --- a/core/lib/Thelia/Form/FirewallForm.php +++ b/core/lib/Thelia/Form/FirewallForm.php @@ -11,6 +11,7 @@ /*************************************************************************************/ namespace Thelia\Form; use Symfony\Component\HttpFoundation\Request; +use Thelia\Core\Translation\Translator; use Thelia\Model\ConfigQuery; use Thelia\Model\FormFirewall; use Thelia\Model\FormFirewallQuery; @@ -35,7 +36,7 @@ abstract class FirewallForm extends BaseForm { $this->firewallInstance = FormFirewallQuery::create() ->filterByFormName($this->getName()) - ->filterByIpAddress($this->request->getClientIp()) + ->filterByIpAddress($request->getClientIp()) ->findOne() ; parent::__construct($request, $type, $data, $options); @@ -103,4 +104,18 @@ abstract class FirewallForm extends BaseForm { return ConfigQuery::read("form_firewall_active", true); } + + public function getWaitingTime() + { + $time = $this->getConfigTime(); + $name = "hour(s)"; + + if ($time < 1) { + $time *= 60; + $name = "minute(s)"; + } + $time = round($time); + + return $time . " " . Translator::getInstance()->trans($name); + } }