Force the Django admin to go through the normal lemonauth:login view rather than its own login

This commit is contained in:
Danielle McLean 2018-04-25 14:49:02 +10:00
parent 0936bcb311
commit 78e6d76693
Signed by: 00dani
GPG key ID: 8EB789DDF3ABD240
2 changed files with 6 additions and 7 deletions

5
lemoncurry/admin.py Normal file
View file

@ -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)

View file

@ -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')),