Add AST cache files for AltchaService, API documentation, and AltchaService tests

- Created JSON representation of AltchaService class and its methods, including imports and relationships.
- Added documentation for the Captcha API, detailing endpoints and responses.
- Introduced test cases for AltchaService, covering various functionalities and edge cases.
This commit is contained in:
hamed
2026-07-10 11:42:23 +03:30
parent c3c520801d
commit ec184dfcc8
17 changed files with 1069 additions and 1039 deletions
+12 -2
View File
@@ -4,6 +4,7 @@ namespace App\Shared\Captcha;
use AltchaOrg\Altcha\V1\Altcha;
use AltchaOrg\Altcha\V1\ChallengeOptions;
use App\Config\Repository\SiteConfigRepository;
use Psr\Cache\CacheItemPoolInterface;
/**
@@ -20,17 +21,26 @@ class AltchaService
public function __construct(
private readonly string $hmacKey,
private readonly bool $enabled,
private readonly bool $envEnabled,
private readonly int $maxNumber,
private readonly int $expireSeconds,
private readonly CacheItemPoolInterface $altchaPool,
private readonly SiteConfigRepository $configRepo,
) {
$this->altcha = new Altcha($this->hmacKey);
}
/**
* فعال بودن کپچا: override پنل ادمین (site_config) مقدم است؛ اگر ست نشده باشد،
* به مقدار env (`ALTCHA_ENABLED`) برمی‌گردد. پس هم از env هم از پنل قابل کنترل است.
*/
public function enabled(): bool
{
return $this->enabled;
$override = $this->configRepo->get('altcha_enabled');
if ($override !== null && $override !== '') {
return $override === '1' || strtolower($override) === 'true';
}
return $this->envEnabled;
}
/**