Peter Sagerson  committed efef6b6

Fix exception on an empty login form.

  • Participants
  • Parent commits 936d87d

Comments (0)

Files changed (3)

File django-otp-agents/docs/source/index.rst

 :func:`~django_agent_trust.decorators.trusted_agent_required` into a single
 decorator that will be satisfied with either a verified user or a trusted agent.
 The default behavior is to act exactly like
-:func:`~django_otp.decorators.otp_required`; Pass ``accept_trusted_agent=True``
+:func:`~django_otp.decorators.otp_required`; pass ``accept_trusted_agent=True``
 to enable the more lenient policy.
 .. automodule:: otp_agents.decorators

File django-otp/django_otp/

         :rasies: :exc:`~django.core.exceptions.ValidationError` if the user is
             not fully authenticated by an OTP token.
+        if user is None:
+            return
         device = self._chosen_device(user)
         token = self.cleaned_data.get('otp_token')
         error = None

File django-otp/django_otp/tests/

 class AuthFormTest(TestCase):
     fixtures = ['tests/alice_and_bob.yaml']
+    def test_empty(self):
+        data = {}
+        form = OTPAuthenticationForm(None, data)
+        self.assert_(not form.is_valid())
+        self.assertEqual(form.get_user(), None)
     def test_bad_password(self):
         data = {
             'username': 'alice',