Skip to content

Commit 82592ac

Browse files
committed
[bugfix] catch different response attribute for prosopo method, resolves #25
1 parent baa82b3 commit 82592ac

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Classes/Domain/Validator/SpamShield/CaptchaMethod.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class CaptchaMethod extends AbstractMethod
2828
*/
2929
protected string $captchaMethod = '';
3030

31+
/**
32+
* @var array|array[]
33+
*/
3134
protected array $captchaConfiguration = [
3235
'recaptcha' => [
3336
'siteVerifyUri' => 'https://www.google.com/recaptcha/api/siteverify',
@@ -134,7 +137,7 @@ protected function verifyCaptchaResponse(): bool
134137

135138
$result = \json_decode($jsonResult);
136139

137-
return (bool)$result->success;
140+
return $this->getExpextedResponseAttribute($result);
138141
}
139142

140143
/**
@@ -219,6 +222,22 @@ protected function getActionName(): string
219222
return $pluginVariables['action'] ?? '';
220223
}
221224

225+
/**
226+
* @param array|\stdClass $result
227+
*
228+
* @return bool
229+
*/
230+
protected function getExpextedResponseAttribute(array|\stdClass $result): bool {
231+
if($this->configuration['captchaMethod'] === 'procaptcha') {
232+
return $result->status === 'ok' && $result->verified;
233+
}
234+
235+
return (bool)$result->success;
236+
}
237+
238+
/**
239+
* @return RequestInterface|null
240+
*/
222241
protected function getRequest(): ?RequestInterface
223242
{
224243
return $GLOBALS['TYPO3_REQUEST'] ?? null;

ext_emconf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'author_email' => 'thomas.rawiel@gmail.com',
99
'state' => 'stable',
1010
'clearCacheOnLoad' => 0,
11-
'version' => '2.1.1',
11+
'version' => '2.1.2',
1212
'constraints' => [
1313
'depends' => [
1414
'typo3' => '12.4.0-12.4.99',

0 commit comments

Comments
 (0)