From 3366de3d78cae0a101f8f79c99260eb69a9feab4 Mon Sep 17 00:00:00 2001 From: Filipe Pina Date: Wed, 13 May 2015 17:48:39 +0100 Subject: [PATCH 1/4] USER_CREATE setting --- googleauth/backends.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/googleauth/backends.py b/googleauth/backends.py index 919868b..f27b616 100644 --- a/googleauth/backends.py +++ b/googleauth/backends.py @@ -5,6 +5,7 @@ IS_STAFF = getattr(settings, 'GOOGLEAUTH_IS_STAFF', False) GROUPS = getattr(settings, 'GOOGLEAUTH_GROUPS', tuple()) APPS_DOMAIN = getattr(settings, 'GOOGLEAUTH_APPS_DOMAIN', None) +USER_CREATE = getattr(settings, 'GOOGLEAUTH_USER_CREATE', True) class GoogleAuthBackend(object): @@ -29,6 +30,9 @@ def authenticate(self, identifier=None, attributes=None): except User.DoesNotExist: + if not USER_CREATE: + return None + user = User.objects.create(username=username, email=email) user.first_name = attributes.get('first_name') or '' user.last_name = attributes.get('last_name') or '' From 8ed422154fa682f694f7b8be6894a2b7ae774046 Mon Sep 17 00:00:00 2001 From: Filipe Pina Date: Wed, 13 May 2015 17:53:29 +0100 Subject: [PATCH 2/4] support for django 1.3 --- googleauth/urls.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/googleauth/urls.py b/googleauth/urls.py index 891da5e..b97b61b 100644 --- a/googleauth/urls.py +++ b/googleauth/urls.py @@ -1,4 +1,8 @@ -from django.conf.urls import * +try: + from django.conf.urls import * +except: + # django 1.3 + from django.conf.urls.defaults import * urlpatterns = patterns('', url(r'^login/$', 'googleauth.views.login', name='googleauth_login'), From 0fefad649fbd40b8a1bfd1cc2af259a19f5b99df Mon Sep 17 00:00:00 2001 From: Filipe Pina Date: Wed, 13 May 2015 18:04:29 +0100 Subject: [PATCH 3/4] typo --- googleauth/urls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googleauth/urls.py b/googleauth/urls.py index b97b61b..3203157 100644 --- a/googleauth/urls.py +++ b/googleauth/urls.py @@ -1,8 +1,8 @@ try: - from django.conf.urls import * + from django.conf.urls import url, patterns except: # django 1.3 - from django.conf.urls.defaults import * + from django.conf.urls.defaults import url, patterns urlpatterns = patterns('', url(r'^login/$', 'googleauth.views.login', name='googleauth_login'), From d6fc338c5c04432a79a7a59c313c5d6df099e600 Mon Sep 17 00:00:00 2001 From: Filipe Pina Date: Wed, 13 May 2015 18:13:01 +0100 Subject: [PATCH 4/4] update readme with GOOGLEAUTH_USER_CREATE --- README.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 18a32a7..d349af4 100644 --- a/README.rst +++ b/README.rst @@ -96,6 +96,9 @@ Optional settings:: # list of default group names to assign to new users GOOGLEAUTH_GROUPS = [] + # create new user if it doesn't exist, default True + GOOGLEAUTH_USER_CREATE = True + URL routes ~~~~~~~~~~ @@ -107,4 +110,4 @@ Add URL config:: ... ) -googleauth doesn't need to be mounted under */auth/*, it can go anywhere. Place it where you see fit for your specific app. \ No newline at end of file +googleauth doesn't need to be mounted under */auth/*, it can go anywhere. Place it where you see fit for your specific app.