feat(auth): integrate Captcha validation in PasswordAuthenticator
- Added CaptchaGuard dependency to PasswordAuthenticator. - Implemented Captcha validation in the authenticate method to enhance security. - Updated the login modal in home.html.twig to redirect to the admin panel instead of opening a modal. - Enhanced the Altcha widget with localized strings for better user experience. - Removed the login modal implementation from home.html.twig to streamline the login process. - Updated manifest.json and AST cache files to reflect changes in the codebase.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Auth\Security;
|
||||
|
||||
use App\Auth\Repository\UserRepository;
|
||||
use App\Shared\Captcha\CaptchaGuard;
|
||||
use App\Shared\Constant\ErrorCodes;
|
||||
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -27,6 +28,7 @@ class PasswordAuthenticator extends AbstractAuthenticator
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly RateLimiterFactory $loginLimiter,
|
||||
private readonly CaptchaGuard $captcha,
|
||||
private readonly int $refreshTokenTtl = 2592000,
|
||||
) {}
|
||||
|
||||
@@ -43,6 +45,9 @@ class PasswordAuthenticator extends AbstractAuthenticator
|
||||
throw new TooManyRequestsHttpException(60, 'تعداد تلاشهای ورود از حد مجاز گذشت');
|
||||
}
|
||||
|
||||
// AppException را ExceptionSubscriber به پاسخ 422 با ERR_CAPTCHA_001 تبدیل میکند.
|
||||
$this->captcha->assertValid($request);
|
||||
|
||||
$data = json_decode($request->getContent(), true) ?? [];
|
||||
$mobile = trim($data['mobile_number'] ?? '');
|
||||
$pass = $data['password'] ?? '';
|
||||
|
||||
Reference in New Issue
Block a user