Check example application for implementation details, but first, please take
a look to `User Profiles`_, it might be what you were looking for.
+ It's possible to disable user creations by django-social-auth with::
+
+ SOCIAL_AUTH_CREATE_USERS = False
+
+ Also, it's possible to associate user accounts that share the same email
+ address if the user entry is unique (that means that if the email is not used
+ by more than one account). This behavior is disabled by default unless::
+
+ SOCIAL_AUTH_ASSOCIATE_BY_MAIL = True
+
-------
Signals
Check example application for implementation details, but first, please take
a look to `User Profiles`_, it might be what you were looking for.
+ It's possible to disable user creations by django-social-auth with::
+
+ SOCIAL_AUTH_CREATE_USERS = False
+
+ Also, it's possible to associate user accounts that share the same email
+ address if the user entry is unique (that means that if the email is not used
+ by more than one account). This behavior is disabled by default unless::
+
+ SOCIAL_AUTH_ASSOCIATE_BY_MAIL = True
+
+
.. _Model Manager: http://docs.djangoproject.com/en/dev/topics/db/managers/#managers
.. _Login URL: http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#login-url
.. _Login redirect URL: http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#login-redirect-url
SignatureMethod_HMAC_SHA1
from django.conf import settings
+from django.core.exceptions import MultipleObjectsReturned
from django.contrib.auth import authenticate
from django.contrib.auth.backends import ModelBackend
from django.utils import simplejson
return getattr(settings, name, default)
CREATE_USERS = _setting('SOCIAL_AUTH_CREATE_USERS', True)
+ASSOCIATE_BY_MAIL = _setting('SOCIAL_AUTH_ASSOCIATE_BY_MAIL', False)
LOAD_EXTRA_DATA = _setting('SOCIAL_AUTH_EXTRA_DATA', True)
FORCE_RANDOM_USERNAME = _setting('SOCIAL_AUTH_FORCE_RANDOM_USERNAME', False)
USERNAME_FIXER = _setting('SOCIAL_AUTH_USERNAME_FIXER', lambda u: u)
if user is None: # new user
if not CREATE_USERS:
return None
- username = self.username(details)
+
email = details.get('email')
- user = User.objects.create_user(username=username, email=email)
- is_new = True
+ if ASSOCIATE_BY_MAIL:
+ try:
+ user = User.objects.get(email=email)
+ except MultipleObjectsReturned:
+ raise ValueError('Not unique email address supplied')
+ except User.DoesNotExist:
+ user = None
+ if not user:
+ username = self.username(details)
+ user = User.objects.create_user(username=username,
+ email=email)
+ is_new = True
social_user = self.associate_auth(user, uid, response, details)
else:
# This account was registered to another user, so we raise an