feat(captcha): add ALTCHA configuration endpoint and integrate into HomeController

- Introduced a new endpoint `/api/v1/altcha/config` in CaptchaController to return the status of the ALTCHA captcha.
- Updated HomeController to inject AltchaService and pass the captcha status to the home page template.
- Modified the home.html.twig template to conditionally render the ALTCHA widget based on the captcha status.
- Updated manifest.json and cache files to reflect changes in the codebase.
This commit is contained in:
hamed
2026-07-10 11:18:40 +03:30
parent 6f2e0ec2f1
commit c3c520801d
15 changed files with 727 additions and 625 deletions
+11
View File
@@ -22,4 +22,15 @@ class CaptchaController extends BaseController
{
return new JsonResponse($this->altcha->createChallenge());
}
#[OA\Get(
path: '/api/v1/altcha/config',
summary: 'وضعیت فعال/غیرفعال بودن کپچا — کلاینت‌ها بر اساس آن widget را رندر می‌کنند',
responses: [new OA\Response(response: 200, description: '{ "enabled": bool }')]
)]
#[Route('/api/v1/altcha/config', methods: ['GET'])]
public function config(): JsonResponse
{
return new JsonResponse(['enabled' => $this->altcha->enabled()]);
}
}
+6 -1
View File
@@ -2,15 +2,20 @@
namespace App\Shared\Controller;
use App\Shared\Captcha\AltchaService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class HomeController extends AbstractController
{
public function __construct(private readonly AltchaService $altcha) {}
#[Route('/', name: 'home', methods: ['GET'])]
public function index(): Response
{
return $this->render('public/home.html.twig');
return $this->render('public/home.html.twig', [
'altcha_enabled' => $this->altcha->enabled(),
]);
}
}