]> git.parisson.com Git - django-social-auth.git/commitdiff
Raise exception if current logged in user is different to user associated with Social...
authorMatías Aguirre <matiasaguirre@gmail.com>
Mon, 31 Jan 2011 13:56:30 +0000 (11:56 -0200)
committerMatías Aguirre <matiasaguirre@gmail.com>
Mon, 31 Jan 2011 13:56:30 +0000 (11:56 -0200)
social_auth/backends/__init__.py

index add4e8631681fb6af35a3dfc2da7a967797ca7ac..97c3d906fda40f6b8b5be3a64220fa919aec3ed7 100644 (file)
@@ -93,6 +93,13 @@ class SocialAuthBackend(ModelBackend):
                 user = User.objects.create_user(username=username, email=email)
             social_user = self.associate_auth(user, uid, response, details)
         else:
+            # This account was registered to another user, so we raise an
+            # error in such case and the view should decide what to do on
+            # at this moment, merging account is not an option because that
+            # would imply update user references on other apps, that's too
+            # much intrusive
+            if 'user' in kwargs and kwargs['user'] != social_user.user:
+                raise ValueError('Account already in use.')
             user = social_user.user
 
         # Update user account data.