From 8fbfce8fe0c147c2caddd2b0e80f65832a16089d Mon Sep 17 00:00:00 2001 From: Siddharth Mitra Date: Thu, 14 Jul 2011 09:21:55 +0530 Subject: [PATCH] Adding exception handling for Value Error: Account already in use, in view.associate_complete --- social_auth/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/social_auth/views.py b/social_auth/views.py index b66d3c0..4526545 100644 --- a/social_auth/views.py +++ b/social_auth/views.py @@ -92,8 +92,15 @@ def associate_complete(request, backend): backend = get_backend(backend, request, request.path) if not backend: return HttpResponseServerError('Incorrect authentication service') - backend.auth_complete(user=request.user) - + + try: + backend.auth_complete(user=request.user) + except ValueError, e: # some Authentication error ocurred + user = None + error_key = getattr(settings, 'SOCIAL_AUTH_ERROR_KEY', None) + if error_key: # store error in session + request.session[error_key] = str(e) + url = request.session.pop(REDIRECT_FIELD_NAME, '') or DEFAULT_REDIRECT if NEW_ASSOCIATION_REDIRECT: url = NEW_ASSOCIATION_REDIRECT -- 2.39.5