python-social-auth,无需断开即可注销

时间:2015-03-29 08:12:53

标签: django python-social-auth

注销后,删除社交登录的访问权限是不是很自然? (用户下次登录时可以使用不同的社交帐户登录)

如何使用python-social-auth?

https://python-social-auth.readthedocs.org/en/latest/pipeline.html#disconnection-pipeline谈及disconnect我认为它接近closing the account而不是logout

Logout with django-social-auth问同样的问题,但答案实际上并没有解决他的问题。

1 个答案:

答案 0 :(得分:1)

只需使用默认的django logout,即使是登录,如果你看到里面的代码,它会询问来自OP的数据并从该数据创建adjango登录。并将所有信息存储在socialauth用户中。 而且python-social-auth在后端有一个社交用户和存储类,它存储了很多东西,所以为了参考你可以查看social_django中的models.py和storage.py。

在我目前使用django和python-social-auth的social-auth-app-django的项目中,我使用的是默认的django注销,

from django.contrib.auth import logout as auth_logout

class logout(TemplateView):

    next_page = settings.LOGOUT_REDIRECT_URL
    redirect_field_name = REDIRECT_FIELD_NAME
    template_name = None
    extra_context = None
    @method_decorator(never_cache)
    def dispatch(self, request, *args, **kwargs):
        auth_logout(request)
        next_page = settings.LOGOUT_REDIRECT_URL
        if next_page:
            return HttpResponseRedirect(next_page)
        return super().dispatch(request, *args, **kwargs)
相关问题