Skip to content

Commit

Permalink
Use filter instead of get to avoid 'Multiple objects returned' error. C…
Browse files Browse the repository at this point in the history
…loses omabgh-52
  • Loading branch information
omab committed May 4, 2011
1 parent 0c885b9 commit a4f932e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions social_auth/views.py
Expand Up @@ -47,9 +47,11 @@ def complete_process(request, backend):
login(request, user)
if getattr(settings, 'SOCIAL_AUTH_SESSION_EXPIRATION', True):
# Set session expiration date if present and not disabled by
# setting
# setting. Use last social-auth instance for current provider,
# users can associate several accounts with a same provider.
backend_name = backend.AUTH_BACKEND.name
social_user = user.social_auth.get(provider=backend_name)
social_user = user.social_auth.filter(provider=backend_name) \
.order_by('-id')[0]
if social_user.expiration_delta():
request.session.set_expiry(social_user.expiration_delta())
url = request.session.pop(REDIRECT_FIELD_NAME, '') or DEFAULT_REDIRECT
Expand Down

0 comments on commit a4f932e

Please sign in to comment.