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

时间:2013-12-15 00:33:52

标签: python django facebook

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

NotAllowedToDisconnect at /disconnect/facebook/1/

这些是我的设置:

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'
)

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

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

1 个答案:

答案 0 :(得分: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))

有关完整示例,请参阅Django example app

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

允许用户进行操作并避免NotAllowedToDisconnectsocial.pipeline.disconnect.allowed_to_disconnect移除SOCIAL_AUTH_DISCONNECT_PIPELINE