add controllers, servoices

This commit is contained in:
root
2026-03-09 02:52:13 -04:00
parent c8de5f7edc
commit d76c871cb7
501 changed files with 34439 additions and 21843 deletions
@@ -0,0 +1,36 @@
<?php
namespace App\Services\Auth;
class RegistrationCaptchaService
{
public function generate(?int $length = null): string
{
$length = $length ?? random_int(4, 8);
$characters = 'ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghjkmnopqrstuvwxyz0123456789';
$captchaText = '';
for ($i = 0; $i < $length; $i++) {
$captchaText .= $characters[random_int(0, strlen($characters) - 1)];
}
session()->put('captcha_answer', $captchaText);
return $captchaText;
}
public function verify(string $input): bool
{
$expected = (string) session()->get('captcha_answer', '');
if ($expected === '') {
return false;
}
return hash_equals($expected, $input);
}
public function clear(): void
{
session()->forget('captcha_answer');
}
}