Skip to content
This repository was archived by the owner on May 13, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~

Expand All @@ -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.
googleauth doesn't need to be mounted under */auth/*, it can go anywhere. Place it where you see fit for your specific app.
4 changes: 4 additions & 0 deletions googleauth/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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 ''
Expand Down
6 changes: 5 additions & 1 deletion googleauth/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from django.conf.urls import *
try:
from django.conf.urls import url, patterns
except:
# django 1.3
from django.conf.urls.defaults import url, patterns

urlpatterns = patterns('',
url(r'^login/$', 'googleauth.views.login', name='googleauth_login'),
Expand Down