-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVerifyCaptcha.class.php
More file actions
36 lines (28 loc) · 1009 Bytes
/
VerifyCaptcha.class.php
File metadata and controls
36 lines (28 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Core\API;
use Core\API\Parameter\StringType;
use Core\Objects\Context;
class VerifyCaptcha extends Request {
public function __construct(Context $context, bool $externalCall = false) {
parent::__construct($context, $externalCall, array(
"captcha" => new StringType("captcha"),
"action" => new StringType("action"),
));
$this->isPublic = false;
}
public function _execute(): bool {
$settings = $this->context->getSettings();
$captchaProvider = $settings->getCaptchaProvider();
if ($captchaProvider === null) {
return $this->createError("No Captcha configured.");
}
$captcha = $this->getParam("captcha");
$action = $this->getParam("action");
$this->success = $captchaProvider->verify($captcha, $action);
$this->lastError = $captchaProvider->getError();
return $this->success;
}
public static function getDescription(): string {
return "Verifies a captcha response. This API is for internal use only.";
}
}