Initialize session when no ID exists

[MAILPOET-4514]
This commit is contained in:
David Remer
2022-07-28 13:34:13 +03:00
committed by Aschepikov
parent 223625bd9b
commit f5c678ec2d
2 changed files with 9 additions and 15 deletions

View File

@@ -56,7 +56,7 @@ class BuiltInCaptchaValidator implements CaptchaValidator {
throw new ValidationError(
__('Please fill in the CAPTCHA.', 'mailpoet'),
[
'redirect_url' => $this->subscriptionUrlFactory->getCaptchaUrl($this->getSessionId()),
'redirect_url' => $this->subscriptionUrlFactory->getCaptchaUrl($this->captchaSession->getId()),
]
);
}
@@ -65,7 +65,7 @@ class BuiltInCaptchaValidator implements CaptchaValidator {
throw new ValidationError(
__('Please regenerate the CAPTCHA.', 'mailpoet'),
[
'redirect_url' => $this->subscriptionUrlFactory->getCaptchaUrl($this->getSessionId()),
'redirect_url' => $this->subscriptionUrlFactory->getCaptchaUrl($this->captchaSession->getId()),
]
);
}
@@ -84,15 +84,6 @@ class BuiltInCaptchaValidator implements CaptchaValidator {
}
private function getSessionId() {
$id = $this->captchaSession->getId();
if ($id === null) {
$this->captchaSession->init();
$id = $this->captchaSession->getId();
}
return $id;
}
public function isRequired($subscriberEmail = null) {
if ($this->isUserExemptFromCaptcha()) {
return false;