omab/django-social-auth — Issue #272: Re-associating & Un-associating accounts not working as expected
Author: ajt
Created: 2012-02-26 14:19:35+00:00
State: open

I am working with the 0.6.6 version via pip and I am getting some odd results when trying to re-associate twitter accounts with an existing user or when I try to remove a facebook account. Here are the steps to reproduce:

1. Create a fresh instance of the example app with 0.6.6
2. Insert facebook and twitter API keys and sync the database
3. Start app via runserver
4. Create account and log in with facebook
5. Associate twitter account
6. Log out
7. Log in with facebook
8. Remove twitter association
9. Log out
10. Log in with facebook
11. Try to associate twitter account, but it does not save.
12. Try to associate the twitter account again and it will save.
13. Try to dis-associate the facebook account and get a DoesNotExist error:
UserSocialAuth matching query does not exist.

I think that has something to do with how social_user is being used in the user.py pipeline.

I am using my own custom pipeline and am getting very odd results in my own app, so I wanted to bring this up to see what you thought.

Here is the traceback from the ```DoesNotExist``` error that is thrown when trying to de-associate a facebook account.

Request Method: GET
Request URL: http://dev.xxxx.com:2222/disconnect/facebook/1/

Django Version: 1.3.1
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'social_auth',
'app']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "/tmp/dsa/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/tmp/dsa/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/tmp/dsa/lib/python2.7/site-packages/social_auth/views.py" in wrapper
48. return func(request, backend, *args, **kwargs)
File "/tmp/dsa/lib/python2.7/site-packages/social_auth/views.py" in disconnect
116. backend.disconnect(request.user, association_id)
File "/tmp/dsa/lib/python2.7/site-packages/social_auth/backends/__init__.py" in disconnect
372. user.social_auth.get(id=association_id).delete()
File "/tmp/dsa/lib/python2.7/site-packages/django/db/models/manager.py" in get
132. return self.get_query_set().get(*args, **kwargs)
File "/tmp/dsa/lib/python2.7/site-packages/django/db/models/query.py" in get
349. % self.model._meta.object_name)

Exception Type: DoesNotExist at /disconnect/facebook/1/
Exception Value: UserSocialAuth matching query does not exist.