mewebstudio / captcha

Captcha for Laravel 5/6/7/8/9/10/11
MIT License
2.44k stars 450 forks source link

Validation is always successful regardless of the entered text #250

Open vaskomichal opened 1 year ago

vaskomichal commented 1 year ago

I used code from documentation

`Session Mode: // [your site path]/Http/routes.php Route::any('captcha-test', function() { if (request()->getMethod() == 'POST') { $rules = ['captcha' => 'required|captcha']; $validator = validator()->make(request()->all(), $rules); if ($validator->fails()) { echo '

Incorrect!

'; } else { echo '

Matched :)

'; } }

    $form = '<form method="post" action="captcha-test">';
    $form .= '<input type="hidden" name="_token" value="' . csrf_token() . '">';
    $form .= '<p>' . captcha_img() . '</p>';
    $form .= '<p><input type="text" name="captcha"></p>';
    $form .= '<p><button type="submit" name="check">Check</button></p>';
    $form .= '</form>';
    return $form;
});`

Validation is always successful regardless of the entered text.

agam-surya commented 1 year ago

yeah me too

laxmanxp commented 1 year ago

for development environment it is showing only captcha and by pass. change the APP_ENV to production or disabled to false in config/captcha.php

Sergej-Tihonov commented 1 year ago

I run into same issue and created a description for the problem with a suggestion for the solution: https://github.com/mewebstudio/captcha/issues/248 Pull Requests with the fix is open. You can review and comment it. Maybe then it can be merged faster?

Erutan409 commented 1 year ago

Ok, so it's not just me....

utqinadhif commented 1 year ago

add CAPTCHA_DISABLE=false to .env, or change APP_ENV to production, then add new lang to your locale with key captcha

Reymoh75 commented 1 year ago

you should use captcha_check() function to validate captcha. pass the submitted string to this function and get a boolean response.

mahyarsaeidifar commented 1 year ago

captcha_check()

what can i use it? where can i use it?

Reymoh75 commented 1 year ago

captcha_check()

what can i use it? where can i use it?

captcha code in entered in an input of a form then will be submit. so you can use captcha_check() function in your controller to check the captcha code. for example if your input in blade has name of "captcha_input", in your controller you should use like this :

if (captcha_check($request->captcha_input) == false) { return back()->with('invalid-captcha','captcha is invalid'); }