Python Social Auth NotAllowedToDisconnect at/disconnect/facebook/1 /

Fil*_*ano 5 python django facebook

我正在尝试在Django应用程序中使用Python Social Auth注销,但我得到了

NotAllowedToDisconnect at /disconnect/facebook/1/
Run Code Online (Sandbox Code Playgroud)

这些是我的设置:

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.get_username',
    'social.pipeline.mail.mail_validation',
    'social.pipeline.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details'
)



SOCIAL_AUTH_DISCONNECT_PIPELINE = (
    'social.pipeline.disconnect.allowed_to_disconnect',
    'social.pipeline.disconnect.get_entries',
    'social.pipeline.disconnect.revoke_tokens',
    'social.pipeline.disconnect.disconnect'
)
Run Code Online (Sandbox Code Playgroud)

这是我在模板上使用的代码

{{ assoc.provider }} (<a href="{% url 'social:disconnect_individual' assoc.provider assoc.id %}" class="disconnect">Disconnect </a>)
Run Code Online (Sandbox Code Playgroud)

Joh*_*son 6

提供单独的注销操作以分离注销和断开连接.

from django.contrib.auth import logout as auth_logout

def logout(request):
    """Logs out user"""
    auth_logout(request)
    return render_to_response('home.html', {}, RequestContext(request))
Run Code Online (Sandbox Code Playgroud)

有关完整示例,请参阅Django示例应用程序.

在您的断开连接管道中social.pipeline.disconnect.allowed_to_disconnect.这将验证用户在当前登录方法断开连接后是否具有有效的登录方式.这是由allowed_to_disconnect处理的.

为了让用户diconnect并且避免NotAllowedToDisconnect去除social.pipeline.disconnect.allowed_to_disconnectSOCIAL_AUTH_DISCONNECT_PIPELINE.