From: Matías Aguirre Date: Mon, 21 Feb 2011 21:16:58 +0000 (-0200) Subject: Moved transaction management to view, Closes gh-23. Closes gh-24 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=cbd37e8e9eefe4cd6e9b464c6fa07695fcb9fc1b;p=django-social-auth.git Moved transaction management to view, Closes gh-23. Closes gh-24 --- diff --git a/social_auth/backends/__init__.py b/social_auth/backends/__init__.py index 6a4a595..2d00e51 100644 --- a/social_auth/backends/__init__.py +++ b/social_auth/backends/__init__.py @@ -21,7 +21,6 @@ from oauth.oauth import OAuthConsumer, OAuthToken, OAuthRequest, \ OAuthSignatureMethod_HMAC_SHA1 from django.conf import settings -from django.db import transaction from django.contrib.auth import authenticate from django.contrib.auth.backends import ModelBackend from django.utils.hashcompat import md5_constructor @@ -115,7 +114,6 @@ class SocialAuthBackend(ModelBackend): social_user.save() return user - authenticate = transaction.commit_on_success(authenticate) def username(self, details): """Return an unique username, if SOCIAL_AUTH_FORCE_RANDOM_USERNAME diff --git a/social_auth/views.py b/social_auth/views.py index e7d4427..9389588 100644 --- a/social_auth/views.py +++ b/social_auth/views.py @@ -3,6 +3,7 @@ from django.conf import settings from django.http import HttpResponseRedirect, HttpResponse, \ HttpResponseServerError from django.core.urlresolvers import reverse +from django.db import transaction from django.contrib.auth import login, REDIRECT_FIELD_NAME from django.contrib.auth.decorators import login_required @@ -17,7 +18,14 @@ def auth(request, backend): return auth_process(request, backend, complete_url, redirect) +@transaction.commit_on_success def complete(request, backend): + """Authentication complete view, override this view if transaction + management doesn't suit your needs.""" + return complete_process(request, backend) + + +def complete_process(request, backend): """Authentication complete process""" backend = get_backend(backend, request, request.path) if not backend: