Revived API /api/v1/captcha.

Now a new captcha is created to check for a bot.
This commit is contained in:
2023-09-19 14:27:33 +06:00
parent 56cd409301
commit 27046e6674
22 changed files with 525 additions and 101 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\V1;
use App\Http\Requests\Api\V1\Captcha\CaptchaRequest;
use App\Http\Resources\Api\V1\Captcha;
use App\Services\Api\V1\CaptchaService;
use Illuminate\Http\JsonResponse;
@@ -12,9 +13,11 @@ final class CaptchaController extends Controller
private readonly CaptchaService $captchaService
) { }
public function getCaptcha(): JsonResponse
public function getCaptcha(CaptchaRequest $request): JsonResponse
{
$result = $this->captchaService->generate();
$captchaPublicToken = $request->getDto();
$expires = now()->addSeconds(config('captcha.waiting_for_captcha_verification_in_seconds'));
$result = $this->captchaService->createKeyWithCaptcha($captchaPublicToken, $expires);
if (!$result->isSuccess()) {
return response()->json($result->getData())->setStatusCode($result->getCode());
}