def manage_auth_already_associated(backend, uid, user=None, *args, **kwargs):
""" OVERRIDED: It will logout the current user
instead of raise an exception
Fix to resolve AuthAlreadyAssociated Exception in Python Social Auth:
http://stackoverflow.com/questions/13018147/authalreadyassociated-exception-in-django-social-auth
"""
provider = backend.name
social = backend.strategy.storage.user.get_social_auth(provider, uid)
if social:
if user and social.user != user:
messages.error(backend.strategy.request, _('This account is already in use.'))
return HttpResponseRedirect(reverse('home'))
# msg = 'This {0} account is already in use.'.format(provider)
# raise AuthAlreadyAssociated(backend, msg)
elif not user:
user = social.user
return {'social': social,
'user': user,
'is_new': user is None,
'new_association': False}
评论列表
文章目录