django-two-factor-auth
django-two-factor-auth copied to clipboard
Cannot validate email (probably after revision 1bedd6fc0767c64ed22415fa02af6d0a8d7ca5ca)
IdempotentSessionWizardView.render_done - line 208/9
Code that used to be in last revision was: if not (form_key in self.idempotent_dict or form_obj.is_valid()): Now there's: if getattr(form_obj, 'idempotent', True) and not form_obj.is_valid():
I suspect the result of that is a second call to form_obj.is_valid() triggers a second check in django_otp/models.py - line 253 - in verify_token() which returns false the second time because it already validated once and the internally kept token was deleted. see: src/django_otp/models.py:251
Possible Solution
The check for idempotent here should be with False default value, then it makes sense not to trigger again the form.is_valid() - as follows: if getattr(form_obj, 'idempotent', False) and not form_obj.is_valid():
Note that I am using latest master branch of django_two_factor_auth, as I need some recent fixes.
Steps to Reproduce (for bugs)
Guess with latest version trying to setup email method...
Your Environment
- Browser and version:
- Python version: 3.7.10
- Django version: 3.2.16
- django-otp version: 1.1.4
- django-two-factor-auth version: master/latest from github
- Link to your project: