1

我使用python-social-auth我的第三方登錄和註銷。首先登錄Facebook,Twitter和Google Plus是成功的(它會詢問我的用戶名/電子郵件和密碼)。我的問題是,當我註銷並通過其中任何一個重新登錄時,我將自動登錄,甚至無需再次詢問我的用戶名/電子郵件和密碼。我沒有註銷?註銷與蟒蛇 - 社會 - 身份驗證

這是我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)) 
+0

試試這個: http://stackoverflow.com/questions/14529815/logout-與-Django的社會身份驗證 –

+0

@NuranAfrasiyabov我已經看到了這個問題,並嘗試每一個解決方案存在,但它並沒有幫助我。即使我退出,仍然登錄Facebook,Twitter和Google Plus。 –

回答

1

所以我在我的網站上測試了這一點。這裏是解釋註銷和斷開行爲的鏈接:(斷開的是,用戶可以問你的項目,「忘掉我的賬戶」的方式) http://python-social-auth.readthedocs.io/en/latest/logging_out.html 正如你所看到的,你需要使用斷開社會化應用斷開。通過你在你的數據庫中刪除用戶協會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> 

在5號後,谷歌,oatuh2第一行表示在數據庫表中的用戶ID。因此,下面圖片中的第一位用戶將被刪除/從我的應用程序斷開連接。 要檢查是否斷開功能的工作與否,看你social_auth_usersocialauth表用戶協會是否已被刪除。 enter image description here 但事實是,只要你通過谷歌聯繫,Facebook的到你自己的應用程序,這意味着你正在登錄,到谷歌或Facebook的網站了。(因爲在第一次登錄就打開Facebook或谷歌的登錄頁面)。即使您從自己的應用程序斷開連接後,也需要從Facebook或Google網站註銷。否則,您的瀏覽器會讓您登錄,當您嘗試再次連接到您的網絡應用時,您將自動登錄。

相關問題