]> git.parisson.com Git - django-social-auth.git/commitdiff
Fix for integrity error on new auth for update_dict
authorChris Kirk <kirk.chris@gmail.com>
Sat, 30 Jun 2012 02:07:32 +0000 (19:07 -0700)
committerChris Kirk <kirk.chris@gmail.com>
Sat, 30 Jun 2012 02:07:32 +0000 (19:07 -0700)
So extra_data is only updated instead of overwritten it was changed
here:
https://github.com/omab/django-social-auth/commit/cafe06eef838a7ee54312e
c42a84a03ade835c0d. However this results in an Integrity error if a new
account is being created for the first time. This fixes that.

social_auth/backends/pipeline/social.py

index dc7d30bc63de4cbf4f75cc65fee83f4706ffd1d3..65e50ecfb44bd5cfcbfc809d650e0d74782926d9 100644 (file)
@@ -22,10 +22,9 @@ def social_auth_user(backend, uid, user=None, *args, **kwargs):
 
     if social_user:
         if user and social_user.user != user:
-            raise AuthException(backend,
-                ugettext('This %(provider)s account is already in use.') % {
-                    'provider': backend.name
-                })
+            raise AuthException(backend, ugettext('This %(provider)s account already in use.') % {
+                'provider':backend.name,
+            })
         elif not user:
             user = social_user.user
     return {'social_user': social_user, 'user': user}
@@ -59,5 +58,8 @@ def load_extra_data(backend, details, response, social_user, uid, user,
     if setting('SOCIAL_AUTH_EXTRA_DATA', True):
         extra_data = backend.extra_data(user, uid, response, details)
         if extra_data and social_user.extra_data != extra_data:
-            social_user.extra_data.update(extra_data)
-            social_user.save()
+            if social_user.extra_data:
+                social_user.extra_data.update(extra_data)
+            else:
+                social_user.extra_data = extra_data
+            social_user.save()
\ No newline at end of file