Skip to content

Commit

Permalink
Fixed #109 -- Catch gateway errors
Browse files Browse the repository at this point in the history
Should be updated to update the wizard form as well, so
no input field or next button is shown.
  • Loading branch information
Bouke committed Jan 5, 2016
1 parent a445591 commit c3c6210
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
20 changes: 14 additions & 6 deletions two_factor/templates/two_factor/core/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ <h1>{% block title %}{% trans "Enable Two-Factor Authentication" %}{% endblock %
<p>{% blocktrans %}Please enter the phone number you wish to be called on.
This number will be validated in the next step. {% endblocktrans %}</p>
{% elif wizard.steps.current == 'validation' %}
{% if device.method == 'call' %}
<p>{% blocktrans %}We are calling your phone right now, please enter the
digits you hear.{% endblocktrans %}</p>
{% elif device.method == 'sms' %}
<p>{% blocktrans %}We sent you a text message, please enter the tokens we
sent.{% endblocktrans %}</p>
{% if challenge_succeeded %}
{% if device.method == 'call' %}
<p>{% blocktrans %}We are calling your phone right now, please enter the
digits you hear.{% endblocktrans %}</p>
{% elif device.method == 'sms' %}
<p>{% blocktrans %}We sent you a text message, please enter the tokens we
sent.{% endblocktrans %}</p>
{% endif %}
{% else %}
<p class="alert alert-warning" role="alert">{% blocktrans %}We've
encountered an issue with the selected authentication method. Please
go back and verify that you entered your information correctly, try
again, or use a different authentication method instead. If the issue
persists, contact the site administrator.{% endblocktrans %}</p>
{% endif %}
{% elif wizard.steps.current == 'yubikey' %}
<p>{% blocktrans %}To identify and verify your YubiKey, please insert a
Expand Down
10 changes: 9 additions & 1 deletion two_factor/views/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from binascii import unhexlify
from base64 import b32encode
import logging

from django.conf import settings
from django.contrib.auth import login as login, REDIRECT_FIELD_NAME
Expand Down Expand Up @@ -40,6 +41,8 @@
backup_phones)
from .utils import (IdempotentSessionWizardView, class_view_decorator)

logger = logging.getLogger(__name__)


@class_view_decorator(sensitive_post_parameters())
@class_view_decorator(never_cache)
Expand Down Expand Up @@ -238,7 +241,12 @@ def render_next_step(self, form, **kwargs):
"""
next_step = self.steps.next
if next_step == 'validation':
self.get_device().generate_challenge()
try:
self.get_device().generate_challenge()
kwargs["challenge_succeeded"] = True
except:
logger.exception("Could not generate challenge")
kwargs["challenge_succeeded"] = False
return super(SetupView, self).render_next_step(form, **kwargs)

def done(self, form_list, **kwargs):
Expand Down

0 comments on commit c3c6210

Please sign in to comment.