First Commit
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Validation;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
class MathCaptchaRule implements Rule
|
||||
{
|
||||
public function passes($attribute, $value): bool
|
||||
{
|
||||
if (!Session::has('math_captcha_answer')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$expected = Session::get('math_captcha_answer');
|
||||
|
||||
Session::forget('math_captcha_answer');
|
||||
Session::forget('math_captcha_question');
|
||||
|
||||
return $value !== null && $value !== '' && (int) $value === (int) $expected;
|
||||
}
|
||||
|
||||
public function message(): string
|
||||
{
|
||||
return __('The captcha answer is incorrect. Please try again.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user