From 38ff645d5d1e0fb7159ac97150ff0e81c5f6b7ba Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sat, 13 Jan 2018 18:09:27 +0100 Subject: [PATCH] Add possibility to turn off django cauth using settings in sample 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/communityauth/sample/django/auth.py b/tools/communityauth/sample/django/auth.py index 5ce4593c..b1c3503b 100644 --- a/tools/communityauth/sample/django/auth.py +++ b/tools/communityauth/sample/django/auth.py @@ -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