[英]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.