Revived API POST /api/v1/captcha.

Captcha validation has been adjusted.
This commit is contained in:
2023-11-26 15:09:42 +06:00
parent 18899c81f2
commit 520a3ba068
21 changed files with 365 additions and 12 deletions

View File

@@ -10,13 +10,24 @@ use Illuminate\Support\Str;
final readonly class CaptchaLogHandler
{
public function handleStore(Captcha $captcha, CaptchaLogType $captchaLogType, HttpUserData $httpUserData): CaptchaLog
public function handleStore(int $captchaId, CaptchaLogType $captchaLogType, HttpUserData $httpUserData): CaptchaLog
{
return $captcha->captchaLogs()->create([
$userAgent = $httpUserData->getUserAgent();
if (!is_null($userAgent)) {
$userAgent = Str::limit($userAgent, 255, '');
}
$referer = $httpUserData->getReferer();
if (!is_null($referer)) {
$referer = Str::limit($referer, 10000, '');
}
return CaptchaLog::create([
'captcha_id' => $captchaId,
'type' => $captchaLogType,
'ip' => $httpUserData->getClientIp(),
'user_agent' => Str::limit($httpUserData->getUserAgent(), 255, ''),
'referer' => Str::limit($httpUserData->getReferer(), 10000, ''),
'user_agent' => $userAgent,
'referer' => $referer,
]);
}
}