我正在使用python-social-auth进行第三方登录和注销。在Facebook,Twitter和Google注册是一个成功的开始(它将询问我的用户名/电子邮件和密码)。我的问题是,当我登录,然后再通过其中任何一个登录,我将自动登录,甚至不问我的用户名/电子邮件和密码再次。我没有注销吗?
这是我的disconnect pipeline
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
'social.pipeline.disconnect.allowed_to_disconnect',
'social.pipeline.disconnect.get_entries',
'social.pipeline.disconnect.revoke_tokens',
'social.pipeline.disconnect.disconnect',
)这是我的注销视图:
from django.contrib.auth import logout as auth_logout
def logout(request):
auth_logout(request)
return render_to_response('logged-out.html', {}, RequestContext(request))发布于 2016-10-20 05:46:58
所以我在我的网站上测试了这个。下面是解释注销和断开连接行为的链接:您可以看到out.html与需要使用断开连接的社交应用程序断开连接(断开是用户可以要求您的项目“忘记我的帐户”的方式)。)。由此,您将删除DB中social_auth_usersocialauth表中的用户关联。要做到这一点,您需要做的是:
**settings.py:**
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
# Verifies that the social association can be disconnected from the current
# user (ensure that the user login mechanism is not compromised by this
# disconnection).
#'social.pipeline.disconnect.allowed_to_disconnect',
# Collects the social associations to disconnect.
'social.pipeline.disconnect.get_entries',
# Revoke any access_token when possible.
'social.pipeline.disconnect.revoke_tokens',
# Removes the social associations.
'social.pipeline.disconnect.disconnect',
)模板中的:
<form id="myform" method="post" action="{% url 'social:disconnect' 'google-oauth2' %}5/?next={{request.path }}">
{% csrf_token %}
<input type="hidden" name="name" value="value" />
<a onclick="document.getElementById('myform').submit();">discon</a>
</form>在第一行中,google 2后面的数字5表示DB表中的用户ID。因此,下面图片中的第一个用户将从我的应用程序中删除/断开连接。若要检查断开功能是否有效,请参见social_auth_usersocialauth表是否已删除用户关联。

但问题是,每当你通过谷歌( google )、facebook连接到你自己的应用程序,就意味着你也在登录谷歌或facebook网站。(就像第一次登录时一样,它会打开facebook或谷歌的登录页面)。即使你与自己的应用程序断开连接,你也需要从facebook或google网站上注销。否则,您的浏览器将保持您的登录,当您试图再次连接到您的web应用程序,您将自动登录。
https://stackoverflow.com/questions/40124914
复制相似问题