From f1c1e6f0ea93d774ab972684c49e919d1e32f05c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Fri, 28 Oct 2011 13:08:36 -0200 Subject: [PATCH] Return User to avoid garbage user creation. Closes gh-169 --- social_auth/backends/pipeline/social.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/social_auth/backends/pipeline/social.py b/social_auth/backends/pipeline/social.py index b1ad80c..6b241ac 100644 --- a/social_auth/backends/pipeline/social.py +++ b/social_auth/backends/pipeline/social.py @@ -18,9 +18,12 @@ def social_auth_user(backend, uid, user=None, *args, **kwargs): except UserSocialAuth.DoesNotExist: social_user = None - if user and social_user and social_user.user != user: - raise ValueError('Account already in use.', social_user) - return {'social_user': social_user} + if social_user: + if user and social_user.user != user: + raise ValueError('Account already in use.', social_user) + elif not user: + user = social_user.user + return {'social_user': social_user, 'user': user} def associate_user(backend, user, uid, social_user=None, *args, **kwargs): @@ -38,7 +41,7 @@ def associate_user(backend, user, uid, social_user=None, *args, **kwargs): return social_auth_user(backend, uid, user, social_user=social_user, *args, **kwargs) else: - return {'social_user': social} + return {'social_user': social, 'user': social.user} def load_extra_data(backend, details, response, social_user, uid, user, -- 2.39.5