Skip to content

Commit

Permalink
Backward compatible django-two-factor-auth urlpatterns
Browse files Browse the repository at this point in the history
  • Loading branch information
millerdev committed Jul 14, 2020
1 parent b5193b8 commit d4c6b0f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion corehq/apps/hqwebapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
TwoFactorSetupView,
)


def two_factor_urls():
def get_urls(urls):
if isinstance(urls, list):
# django-two-factor-auth==1.6.2
return urls
# django-two-factor-auth~=1.12
assert isinstance(urls, tuple) and isinstance(urls[0], list), urls
return urls[0]
return get_urls(tf_urls) + get_urls(tf_twilio_urls), 'two_factor'


urlpatterns = [
url(r'^$', redirect_to_default),
url(r'^homepage/$', redirect_to_default, name='homepage'),
Expand Down Expand Up @@ -78,7 +90,7 @@
url(r'^account/two_factor/backup/phone/register/$', TwoFactorPhoneSetupView.as_view(), name=TwoFactorPhoneSetupView.urlname),
url(r'^account/two_factor/backup/phone/unregister/(?P<pk>\d+)/$', TwoFactorPhoneDeleteView.as_view(),
name=TwoFactorPhoneDeleteView.urlname),
url(r'', include((tf_urls[0] + tf_twilio_urls[0], 'two_factor'), namespace='two_factor')),
url(r'', include(two_factor_urls(), namespace='two_factor')),
url(r'^account/two_factor/reset/$', TwoFactorResetView.as_view(), name=TwoFactorResetView.urlname),
url(r'^hq/admin/session_details/$', SessionDetailsView.as_view(),
name=SessionDetailsView.urlname),
Expand Down

0 comments on commit d4c6b0f

Please sign in to comment.