From 63ab4b968ab13206eeacbd79655e9a28902e592e Mon Sep 17 00:00:00 2001 From: Miguel Araujo Perez Date: Wed, 16 Feb 2011 10:58:05 +0100 Subject: [PATCH] Wrapping authenticate within a transaction.commit_on_success decorator, that ensures no inconsistent data can be stored if something fails. --- social_auth/backends/__init__.py | 2 ++ 1 file changed, 2 insertions(+) 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 -- 2.39.5