pipeline.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:django-unifi-portal 作者: bsab 项目源码 文件源码
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}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号