Skip to content

Commit

Permalink
Return User to avoid garbage user creation. Closes omabgh-169
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Oct 28, 2011
1 parent 79815a7 commit f1c1e6f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions social_auth/backends/pipeline/social.py
Expand Up @@ -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):
Expand All @@ -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,
Expand Down

0 comments on commit f1c1e6f

Please sign in to comment.