From: Miguel Araujo Perez Date: Wed, 16 Feb 2011 09:58:05 +0000 (+0100) Subject: Wrapping authenticate within a transaction.commit_on_success decorator, that ensures... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=63ab4b968ab13206eeacbd79655e9a28902e592e;p=django-social-auth.git Wrapping authenticate within a transaction.commit_on_success decorator, that ensures no inconsistent data can be stored if something fails. --- diff --git a/social_auth/backends/__init__.py b/social_auth/backends/__init__.py index 97c3d90..b3e6d4e 100644 --- a/social_auth/backends/__init__.py +++ b/social_auth/backends/__init__.py @@ -21,6 +21,7 @@ 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 @@ -113,6 +114,7 @@ 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