You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I override the default django.contrib.auth.forms.AuthenticationForm with a subclass that has a CaptchaField added, within the context of the above wizard, I always get form validation error on the captcha field. I did some investigating and it looks like the clean method of the CaptchaField is getting called a bunch (5-10 times?) and so, it's coming back valid maybe the first time and finally, the CaptchaStore gets deleted at some point and CaptchaStore.DoesNotExist gets triggered.
As a hack, I've just overridden the clean method so that it doesn't call delete on the CaptchaStore instance. This seems to work ... idk what the security implications are yet. I'm thinking that remove_expired() will maybe do just as well.
The text was updated successfully, but these errors were encountered:
Deletion is necessary part of captcha validation. Otherwise a single captcha image could be used to pass multiple forms. In my opinion, there is something wrong with the django-two-factor-auth or your application, because no form should be validated more than once.
I haven't used the wizard myself, but I probably found the source of the problem in django-formtools. Anyhow IdempotentSessionWizardView seems to be able to mitigate that problem according to its description.
Same problem for me, spend almost whole day trying to figure out some kind of captcha validation caching, but in the end realized that it's probably going to be easier to switch to django-recaptcha.
I'm trying to shim in a captcha to this wizard: https://github.com/Bouke/django-two-factor-auth/blob/master/two_factor/views/core.py#L64
When I override the default
django.contrib.auth.forms.AuthenticationForm
with a subclass that has aCaptchaField
added, within the context of the above wizard, I always get form validation error on the captcha field. I did some investigating and it looks like the clean method of the CaptchaField is getting called a bunch (5-10 times?) and so, it's coming back valid maybe the first time and finally, theCaptchaStore
gets deleted at some point andCaptchaStore.DoesNotExist
gets triggered.As a hack, I've just overridden the
clean
method so that it doesn't calldelete
on theCaptchaStore
instance. This seems to work ... idk what the security implications are yet. I'm thinking thatremove_expired()
will maybe do just as well.The text was updated successfully, but these errors were encountered: