Refactor the captcha system
The current Captcha class has a lot of responsibilities. It renders the captcha image, can check if a certain captcha type is a Google captcha, if a captcha is required for a certain email. The SubscriberSubscribeController is not only in charge of "controlling" the subscription process but also validates, whether a captcha is correct or not. This architecture made it difficult to extend the functionality and introduce the audio captcha feature. Therefore this commit refactors the captcha architecture and tries to seperate the different concerns into several classes and objects. Validation is now done by validators. The CaptchaPhrase now is in charge of keeping the captcha phrase consistent between the image and the new audio, so that you can renew the captcha and both captchas are in sync. [MAILPOET-4514]
This commit is contained in:
@ -5,7 +5,7 @@ namespace MailPoet\API\JSON;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\Exception;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Subscription\Captcha;
|
||||
use MailPoet\Subscription\Captcha\CaptchaConstants;
|
||||
use MailPoet\Tracy\ApiPanel\ApiPanel;
|
||||
use MailPoet\Tracy\DIPanel\DIPanel;
|
||||
use MailPoet\Util\Helpers;
|
||||
@ -100,7 +100,7 @@ class API {
|
||||
}
|
||||
|
||||
$ignoreToken = (
|
||||
$this->settings->get('captcha.type') != Captcha::TYPE_DISABLED &&
|
||||
$this->settings->get('captcha.type') != CaptchaConstants::TYPE_DISABLED &&
|
||||
$this->requestEndpoint === 'subscribers' &&
|
||||
$this->requestMethod === 'subscribe'
|
||||
);
|
||||
|
Reference in New Issue
Block a user