diff --git a/Classes/Configuration.php b/Classes/Configuration.php index b6e6726..a757970 100644 --- a/Classes/Configuration.php +++ b/Classes/Configuration.php @@ -15,7 +15,7 @@ class Configuration protected string $siteKey = ''; protected string $siteSecretKey = ''; - protected string $puzzleEndpoint = ''; + protected bool $useEuPuzzleEndpoint = false; protected string $verifyUrl = ''; protected string $jsPath = ''; protected bool $skipDevValidation = false; @@ -31,7 +31,7 @@ public function __construct(Site $site = null) $siteConfiguration = $site->getConfiguration(); $this->siteKey = trim($siteConfiguration['friendlycaptcha_site_key'] ?? ''); $this->siteSecretKey = trim($siteConfiguration['friendlycaptcha_secret_key'] ?? ''); - $this->puzzleEndpoint = trim($siteConfiguration['friendlycaptcha_puzzle_endpoint'] ?? ''); + $this->useEuPuzzleEndpoint = $siteConfiguration['friendlycaptcha_use_eu_puzzle_endpoint'] ?? false; $this->verifyUrl = trim($siteConfiguration['friendlycaptcha_verify_url'] ?? ''); $this->jsPath = trim($siteConfiguration['friendlycaptcha_js_path'] ?? ''); $this->skipDevValidation = (bool)($siteConfiguration['friendlycaptcha_skip_dev_validation'] ?? false); @@ -52,9 +52,9 @@ public function getSiteSecretKey(): string return $this->siteSecretKey; } - public function getPuzzleEndpoint(): string + public function useEuPuzzleEndpoint(): bool { - return $this->puzzleEndpoint; + return $this->useEuPuzzleEndpoint; } public function getVerifyUrl(): string diff --git a/Classes/ViewHelpers/ConfigurationViewHelper.php b/Classes/ViewHelpers/ConfigurationViewHelper.php index ea1356c..ea05c4f 100644 --- a/Classes/ViewHelpers/ConfigurationViewHelper.php +++ b/Classes/ViewHelpers/ConfigurationViewHelper.php @@ -18,7 +18,7 @@ public static function render() return [ 'siteKey' => $configuration->getSiteKey(), 'verifyUrl' => $configuration->getVerifyUrl(), - 'puzzleEndpoint' => $configuration->getPuzzleEndpoint(), + 'useEuPuzzleEndpoint' => $configuration->useEuPuzzleEndpoint(), 'jsPath' => $configuration->getJsPath(), 'enabled' => $configuration->isEnabled(), ]; diff --git a/Configuration/SiteConfiguration/Overrides/sites.php b/Configuration/SiteConfiguration/Overrides/sites.php index fb153d8..2fdf7f3 100644 --- a/Configuration/SiteConfiguration/Overrides/sites.php +++ b/Configuration/SiteConfiguration/Overrides/sites.php @@ -17,12 +17,10 @@ static function () { 'placeholder' => 'A16UE6NICBMVQKG1I1BFMLBD56K53D3CS0L5N00AJNBT1R41P8O7N1KFMH', ], ]; - $GLOBALS['SiteConfiguration']['site']['columns']['friendlycaptcha_puzzle_endpoint'] = [ + $GLOBALS['SiteConfiguration']['site']['columns']['friendlycaptcha_use_eu_puzzle_endpoint'] = [ 'label' => $lll . 'site.configuration.puzzle_endpoint', 'config' => [ - 'type' => 'input', - 'placeholder' => 'eu', - 'default' => '', + 'type' => 'check', ], ]; $GLOBALS['SiteConfiguration']['site']['columns']['friendlycaptcha_verify_url'] = [ @@ -48,6 +46,6 @@ static function () { 'type' => 'check', ], ]; - $GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] .= ',--div--;' . $lll . 'site.configuration.tab, friendlycaptcha_site_key,friendlycaptcha_secret_key,friendlycaptcha_puzzle_endpoint,friendlycaptcha_verify_url,friendlycaptcha_js_path,friendlycaptcha_skip_dev_validation,'; + $GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] .= ',--div--;' . $lll . 'site.configuration.tab, friendlycaptcha_site_key,friendlycaptcha_secret_key,friendlycaptcha_use_eu_puzzle_endpoint,friendlycaptcha_verify_url,friendlycaptcha_js_path,friendlycaptcha_skip_dev_validation,'; } ); diff --git a/Documentation/Configuration/Integration.rst b/Documentation/Configuration/Integration.rst index cafcab6..d0cb191 100644 --- a/Documentation/Configuration/Integration.rst +++ b/Documentation/Configuration/Integration.rst @@ -26,6 +26,9 @@ A new tab **Friendly Captcha** is available which includes all configuration opt This is described in the :ref:`using` section! +By default, the global endpoint `https://global.frcapi.com/api/v2/captcha/siteverify` is used. +If you prefer to use the EU endpoint, enter `https://eu.frcapi.com/api/v2/captcha/siteverify` in `Verify URL` field and ensure that the `Use EU Puzzle Endpoint` option is checked. + Working with automated tests ============================ If you are using automated tests you might want to skip the captcha. diff --git a/Documentation/Images/configuration_site.png b/Documentation/Images/configuration_site.png index 1130f8a..81c93f9 100644 Binary files a/Documentation/Images/configuration_site.png and b/Documentation/Images/configuration_site.png differ diff --git a/Documentation/Using/Custom.rst b/Documentation/Using/Custom.rst index 04cb72d..c11ab17 100644 --- a/Documentation/Using/Custom.rst +++ b/Documentation/Using/Custom.rst @@ -24,7 +24,7 @@ The puzzle needs to be integrated into the form. This can be done like this in y -
+

{f:translate(key:'LLL:EXT:friendlycaptcha_official/Resources/Private/Language/locallang.xlf:configuration_missing')}

diff --git a/Documentation/V2_Migration/Index.rst b/Documentation/V2_Migration/Index.rst index 91ab2ca..0150621 100644 --- a/Documentation/V2_Migration/Index.rst +++ b/Documentation/V2_Migration/Index.rst @@ -11,6 +11,6 @@ If you’re currently using an earlier version of the plugin with **Friendly Cap * Enable **V2** in yout Application in the Panel at https://friendlycaptcha.com/ * Install the newest version of the plugin (min v1.0) * In TYPO3 backend, go to the *Site Management*/*Sites* module and switch to the **FriendlyCaptcha** tab. You need to change the URLs -**Puzzle Endpoint** - save empty or `eu` if you want to use the EU Endpoint +**Puzzle Endpoint** - check it if you want to use the EU Endpoint **Verify URL** - `https://global.frcapi.com/api/v2/captcha/siteverify` or `https://eu.frcapi.com/api/v2/captcha/siteverify` if you prefer to use EU endpoint **JavaScript Path** - `EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js` \ No newline at end of file diff --git a/Resources/Private/Form/Partials/Friendlycaptcha.html b/Resources/Private/Form/Partials/Friendlycaptcha.html index 7a85df0..f34c94f 100644 --- a/Resources/Private/Form/Partials/Friendlycaptcha.html +++ b/Resources/Private/Form/Partials/Friendlycaptcha.html @@ -24,7 +24,7 @@ value="1" additionalAttributes="{formvh:translateElementProperty(element: element, property: 'fluidAdditionalAttributes')}" /> -
+
diff --git a/Resources/Private/Language/Configuration.xlf b/Resources/Private/Language/Configuration.xlf index 9124165..b9d8e44 100644 --- a/Resources/Private/Language/Configuration.xlf +++ b/Resources/Private/Language/Configuration.xlf @@ -15,7 +15,7 @@ Verify URL - Puzzle Endpoint + Use EU Puzzle Endpoint JavaScript Path diff --git a/Resources/Private/Powermail/Partials/Form/Field/Friendlycaptcha.html b/Resources/Private/Powermail/Partials/Form/Field/Friendlycaptcha.html index b775d6e..15e86cd 100644 --- a/Resources/Private/Powermail/Partials/Form/Field/Friendlycaptcha.html +++ b/Resources/Private/Powermail/Partials/Form/Field/Friendlycaptcha.html @@ -6,7 +6,7 @@ -
+

{f:translate(key:'LLL:EXT:friendlycaptcha_official/Resources/Private/Language/locallang.xlf:configuration_missing')}

diff --git a/Tests/Unit/ConfigurationTest.php b/Tests/Unit/ConfigurationTest.php index a1f01d9..4202093 100644 --- a/Tests/Unit/ConfigurationTest.php +++ b/Tests/Unit/ConfigurationTest.php @@ -22,7 +22,7 @@ public function configurationIsBuiltCorrectly(): void $configuration = new Configuration(); self::assertEquals('12345', $configuration->getSiteKey()); self::assertEquals('ABCDEF', $configuration->getSiteSecretKey()); - self::assertEquals('', $configuration->getPuzzleEndpoint()); + self::assertFalse($configuration->useEuPuzzleEndpoint()); self::assertEquals('https://verify,https://verify2', $configuration->getVerifyUrl()); self::assertEquals('https://verify', $configuration->getFirstVerifyUrl()); self::assertTrue($configuration->isEnabled()); diff --git a/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php b/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php index e5ae211..19e0626 100644 --- a/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php @@ -23,7 +23,7 @@ public function viewHelperReturnsProperConfiguration() self::assertSame([ 'siteKey' => '1234', 'verifyUrl' => 'https://verify,https://verify2', - 'puzzleEndpoint' => '', + 'useEuPuzzleEndpoint' => false, 'jsPath' => 'EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js', 'enabled' => true, ], $configurationViewHelper->render());