Change error message
modifié: core/lib/Thelia/Controller/BaseController.php modifié: core/lib/Thelia/Form/FirewallForm.php
This commit is contained in:
@@ -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(),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user