From 5d5cf4c81393fb4e89f841b0f64a9c3345513ae4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Mon, 31 Jan 2011 11:56:30 -0200 Subject: [PATCH] Raise exception if current logged in user is different to user associated with Social Account --- social_auth/backends/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) 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. -- 2.39.5