From: Matías Aguirre Date: Mon, 31 Jan 2011 13:56:30 +0000 (-0200) Subject: Raise exception if current logged in user is different to user associated with Social... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5d5cf4c81393fb4e89f841b0f64a9c3345513ae4;p=django-social-auth.git Raise exception if current logged in user is different to user associated with Social Account --- diff --git a/social_auth/backends/__init__.py b/social_auth/backends/__init__.py index add4e86..97c3d90 100644 --- a/social_auth/backends/__init__.py +++ b/social_auth/backends/__init__.py @@ -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.