Python Social Auth NotAllowedToDisconnect at / disconnect / facebook / 1 / [英] Python Social Auth NotAllowedToDisconnect at /disconnect/facebook/1/

查看:169
本文介绍了Python Social Auth NotAllowedToDisconnect at / disconnect / facebook / 1 /的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Django应用程序中使用Python Social Auth注销,但是我正在获得

  NotAllowedToDisconnect / 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_entr
'social.pipeline.disconnect.revoke_tokens',
'social.pipeline.disconnect.disconnect'

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

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


解决方案

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

 从django.contrib.auth导入注销为auth_logout 

def logout(request):

auth_logout(request)
return render_to_response('home.html',{},RequestContext(request))

请参阅 Django示例应用程序为一个完整的例子。



在你的断开管道您有 social.pipeline.disconnect.allowed_to_disconnect 。这将验证用户在当前登录方法已断开连接后是否具有有效的登录方式。这是在 allowed_to_disconnect 的句柄。 py#L23rel =nofollow noreferrer> django_orm.py#L23



允许用户diconnect并避免 NotAllowedToDisconnect SOCIAL_AUTH_DISCONNECT_PIPELINE 中删除​​ social.pipeline.disconnect.allowed_to_disconnect / p>

I'm trying to use logout with Python Social Auth in a Django app, but I'm getting

NotAllowedToDisconnect at /disconnect/facebook/1/

These are my settings:

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

And this is the code I'm using on templates

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

解决方案

Provide a separate logout action to separate logout and disconnect.

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

Refer to the Django example app for a full example.

In your disconnect pipeline you have social.pipeline.disconnect.allowed_to_disconnect. This will verify that the user has a valid way to login after the current login method has been disconnected. This is handle by allowed_to_disconnect in django_orm.py#L23.

To allow the user to diconnect and to avoid the NotAllowedToDisconnect remove the social.pipeline.disconnect.allowed_to_disconnect from your SOCIAL_AUTH_DISCONNECT_PIPELINE.

这篇关于Python Social Auth NotAllowedToDisconnect at / disconnect / facebook / 1 /的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆