简体   繁体   English

如果我进行自定义管道,则Django和Python-Social-Auth重定向

[英]Django and Python-Social-Auth redirect if I make custom pipeline

This is my project's directory: 这是我的项目的目录:

/handshakeapp:
    templates/
    __init__.py
    admin.py
    models.py
    pipelines.py
    views.py
/VKHandshake:
    __init__.py
    settings.py
    urls.py
    ...
manage.py

This is part of settings.py 这是settings.py一部分

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.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
    'handshakeapp.pipelines.fill_extendeduser'
)

This is handshakeapp/pipelines.py : 这是handshakeapp/pipelines.py

from models import ExtendedUser

def fill_extendeduser(strategy, details, user=None, is_new=False, *args, **kwargs):
    if user and is_new:
        user.extendeduser_set.create(user=user.get_username(), countingID=None, profilePic='http://localhost:8000/pic.png')

But it redirects to /accounts/login/ every time I try to login using Social Auth. 但是,每次我尝试使用社交身份验证登录时,它都会重定向到/accounts/login/ It works if I remove 'handshakeapp.pipelines.fill_extendeduser' from SOCIAL_AUTH_PIPELINE. 如果我从SOCIAL_AUTH_PIPELINE中删除了'handshakeapp.pipelines.fill_extendeduser' ,它'handshakeapp.pipelines.fill_extendeduser'起作用。 What's wrong? 怎么了?

The problem was in fill_extendeduser function. 问题出在fill_extendeduser函数中。 It raised an exception and, as mentioned by @omab: 如@omab所述,它引发了一个异常,并且:

Django auth process will eat the exceptions and redirect to the value of LOGIN_URL which by default is /accounts/login/. Django auth进程将吃掉异常并重定向到LOGIN_URL的值,默认情况下为/ accounts / login /。 So, add a try/except block around your code to check if it's raising any error. 因此,在代码周围添加一个try / except块,以检查是否引发任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何测试自定义的python-social-auth管道? - How to test a custom python-social-auth pipeline? python-social-auth和Django,用自定义模型替换UserSocialAuth - python-social-auth and Django, replace UserSocialAuth with custom model 自定义用户 model 与 django 上的 python-social-auth - Custom user model with python-social-auth on django python-social-auth-如何在Django中断开连接? - python-social-auth - how could I disconnect in Django? Python-Social-Auth在mongoEngine(Django)上失败 - Python-Social-Auth fails with mongoEngine (Django) 使用python-social-auth的自定义登录过程 - Custom login process with python-social-auth 使用python-social-auth的django社交认证错误 - django social authentication error using python-social-auth 我正在使用python-social-auth查找访问人员在管道中间使用的后端提供程序 - Using python-social-auth I'm looking to access what backend provider the person is using in the middle of the pipeline 当我尝试获取 access_token 时,Python-social-auth 管道返回 TypeError - Python-social-auth pipeline returns TypeError when I'm trying to get access_token 如何使用 python-social-auth 和 django-graphql-auth 返回刷新令牌? - How can I return the refresh token using python-social-auth and django-graphql-auth?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM