Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Captcha validation returns always wrong captcha error #153

Open
MoslemCherif opened this issue Dec 12, 2018 · 1 comment
Open

Captcha validation returns always wrong captcha error #153

MoslemCherif opened this issue Dec 12, 2018 · 1 comment

Comments

@MoslemCherif
Copy link

MoslemCherif commented Dec 12, 2018

I could display the captcha, everything is fine, until I submit, there comes the validation error "Wrong Captcha".
After debugging, I saw that in the class Mews\Captcha\Captcha, there is a session value clearing $this->session->remove('captcha'); which leads to this problem.
As a suggestion, the session key should be removed after successful result
I am using Laravel 5.1 and PHP version 5.6

@mauricius
Copy link

That's the point of a Captcha code. You don't want to show the same string if the validation fails, otherwise your captcha can be cracked easily using a brute force approach.

If you're submitting the form using a normal POST request you should see a new code after each validation failure. Otherwise, if you are using AJAX requests you have to make sure that the captcha image is refreshed after the failed validation.

Something like this should work for you

<img id="captcha" src="{{ Captcha::src() }}" alt="captcha">

And the jQuery code that handles the refresh

var source = $("#captcha").attr('src');

$("#captcha").attr('src', source + '?timestamp=' + new Date().getTime());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants