Analytics.php
3 years ago
AutomatedLatestContent.php
2 months ago
AutomaticEmails.php
3 years ago
Captcha.php
1 year ago
Coupons.php
2 years ago
CustomFields.php
2 months ago
DynamicProducts.php
1 year ago
DynamicSegments.php
2 months ago
FeatureFlags.php
3 years ago
Forms.php
2 months ago
Help.php
1 year ago
ImportExport.php
2 months ago
Mailer.php
1 year ago
NewsletterLinks.php
2 months ago
NewsletterTemplates.php
2 months ago
Newsletters.php
2 months ago
Premium.php
10 months ago
RedirectResponse.php
1 year ago
Segments.php
2 months ago
SendingQueue.php
2 months ago
Services.php
6 months ago
Settings.php
2 months ago
Setup.php
1 year ago
StatisticsExport.php
3 months ago
SubscriberStats.php
1 month ago
Subscribers.php
2 months ago
Tags.php
3 years ago
UserFlags.php
2 years ago
WoocommerceProductVariations.php
2 months ago
WoocommerceSettings.php
3 years ago
index.php
3 years ago
Captcha.php
37 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\API\JSON\v1; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\API\JSON\Endpoint as APIEndpoint; |
| 9 | use MailPoet\Captcha\CaptchaSession; |
| 10 | use MailPoet\Captcha\CaptchaUrlFactory; |
| 11 | use MailPoet\Config\AccessControl; |
| 12 | |
| 13 | class Captcha extends APIEndpoint { |
| 14 | private CaptchaSession $captchaSession; |
| 15 | private CaptchaUrlFactory $urlFactory; |
| 16 | |
| 17 | public $permissions = [ |
| 18 | 'global' => AccessControl::NO_ACCESS_RESTRICTION, |
| 19 | ]; |
| 20 | |
| 21 | public function __construct( |
| 22 | CaptchaSession $captchaSession, |
| 23 | CaptchaUrlFactory $urlFactory |
| 24 | ) { |
| 25 | $this->captchaSession = $captchaSession; |
| 26 | $this->urlFactory = $urlFactory; |
| 27 | } |
| 28 | |
| 29 | public function render(array $data = []) { |
| 30 | $sessionId = $this->captchaSession->generateSessionId(); |
| 31 | $data = array_merge($data, ['captcha_session_id' => $sessionId]); |
| 32 | $captchaUrl = $this->urlFactory->getCaptchaUrl($data); |
| 33 | |
| 34 | return $this->redirectResponse($captchaUrl); |
| 35 | } |
| 36 | } |
| 37 |