您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

django – python-social-auth部分管道无法恢复

5b51 2022/1/14 8:22:40 python 字数 3523 阅读 529 来源 www.jb51.cc/python

我正在尝试使用 python-social-auth的部分管道为新用户收集密码.由于某些未知原因,我无法恢复管道,在提交表单后页面呈现回密码收集页面. 有线的是,即使我输入了http … / complete / backend-name,页面也会重定向回密码集合页面.看起来渲染进入无限循环,密码收集页面首先指向完整页面,完整页面直接返回密码收集页面.我检查了REDIRECT_FIELD_NAME

概述

有线的是,即使我输入了http … / complete / backend-name,页面也会重定向回密码集合页面.看起来渲染进入无限循环,密码收集页面首先指向完整页面,完整页面直接返回密码收集页面.我检查了REDIRECT_FIELD_NAME的值,它是“下一步”.

我不确定我的代码有什么问题,非常感谢任何提示/建议.

settings.py

SOCIAL_AUTH_PIPELINE = (
    ...
    'accounts.pipeline.get_password',...
)

pipeline.py

from django.shortcuts import redirect
from social.pipeline.partial import partial

@partial
def get_password(strategy,details,user=None,is_new=False,*args,**kwargs):
    if is_new:
        return redirect('accounts_signup_social')
    else:
        return

views.py

def get_password(request):
    if request.method == 'POST':
        request.session['password'] = request.POST.get('password')
        backend = request.session['partial_pipeline']['backend']
        return redirect('social:complete',backend=backend)
    return render_to_response('accounts/social_signup.html',{"form":SocialSignUpForm},RequestContext(request))

正如文档所说,“管道将恢复与削减流程相同的功能.”在http://python-social-auth.readthedocs.org/en/latest/pipeline.html.这意味着它将始终渲染回相同的功能.

解决方案是在管道中添加密码的会话检查.如果密码存档,则返回下一个管道:

管道:

from django.shortcuts import redirect
from social.pipeline.partial import partial

@partial
def get_password(strategy,**kwargs):
    if is_new:
        if 'password' in kwargs['request'].session:
            return {'password': kwargs['request'].session['psssword']}
        else:
            return redirect('accounts_signup_social')
    else:
        return

总结

以上是编程之家为你收集整理的django – python-social-auth部分管道无法恢复全部内容,希望文章能够帮你解决django – python-social-auth部分管道无法恢复所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶