From: Matías Aguirre Date: Fri, 28 Oct 2011 15:08:36 +0000 (-0200) Subject: Return User to avoid garbage user creation. Closes gh-169 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f1c1e6f0ea93d774ab972684c49e919d1e32f05c;p=django-social-auth.git Return User to avoid garbage user creation. Closes gh-169 --- 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,