Add possibility to turn off django cauth using settings in sample
authorMagnus Hagander <magnus@hagander.net>
Sat, 13 Jan 2018 17:09:27 +0000 (18:09 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sat, 13 Jan 2018 17:09:27 +0000 (18:09 +0100)
This sample is used across most of our other sites, so add functionality
to install without having a local master repo.

Back-patch of pgeu commit 3e4d8c9101c2d309b134c2f5638aa40db8ef2cf5

tools/communityauth/sample/django/auth.py

index 5ce4593c020bf54fbc3798be99b79db78a46f1d6..b1c3503b1291135534f776a9f3e08569ea84ab83 100644 (file)
@@ -48,6 +48,11 @@ class AuthBackend(ModelBackend):
 
 # Handle login requests by sending them off to the main site
 def login(request):
+       if not hasattr(settings, 'PGAUTH_REDIRECT'):
+               # No pgauth installed, so allow local installs.
+               from django.contrib.auth.views import login
+               return login(request, template_name='admin.html')
+
        if request.GET.has_key('next'):
                # Put together an url-encoded dict of parameters we're getting back,
                # including a small nonce at the beginning to make sure it doesn't