From 78e6d766930ee687f06e86e0c0dc4c9db04a9dc2 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 25 Apr 2018 14:49:02 +1000 Subject: [PATCH] Force the Django admin to go through the normal lemonauth:login view rather than its own login --- lemoncurry/admin.py | 5 +++++ lemoncurry/urls.py | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 lemoncurry/admin.py diff --git a/lemoncurry/admin.py b/lemoncurry/admin.py new file mode 100644 index 0000000..2b7b568 --- /dev/null +++ b/lemoncurry/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin +from otp_agents.decorators import otp_required + + +admin.site.login = otp_required(admin.site.login, accept_trusted_agent=True) diff --git a/lemoncurry/urls.py b/lemoncurry/urls.py index 9e6535e..87660c0 100644 --- a/lemoncurry/urls.py +++ b/lemoncurry/urls.py @@ -17,17 +17,11 @@ from django.conf import settings from django.conf.urls import include, url from django.contrib import admin from django.views.generic import RedirectView -from otp_agents.admin import TrustedAgentAdminSite import django.contrib.sitemaps.views as sitemap from entries.sitemaps import EntriesSitemap from home.sitemaps import HomeSitemap -otp_admin_site = TrustedAgentAdminSite() -for model_cls, model_admin in admin.site._registry.items(): - otp_admin_site.register(model_cls, model_admin.__class__) - - sections = { 'entries': EntriesSitemap, 'home': HomeSitemap, @@ -40,7 +34,7 @@ urlpatterns = [ url('', include('users.urls')), url(r'^\.well-known/', include('wellknowns.urls')), url('^admin/doc/', include('django.contrib.admindocs.urls')), - url('^admin/', otp_admin_site.urls), + url('^admin/', admin.site.urls), url('^auth/', include('lemonauth.urls')), url(r'^favicon\.ico$', RedirectView.as_view( url=settings.MEDIA_URL + 'favicon/favicon.ico')),