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

Cannot validate email (probably after revision 1bedd6fc0767c64ed22415fa02af6d0a8d7ca5ca) #580

Open
rubmz opened this issue Jan 4, 2023 · 0 comments

Comments

@rubmz
Copy link

rubmz commented Jan 4, 2023

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:
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

1 participant