簡體   English   中英

如果我進行自定義管道,則Django和Python-Social-Auth重定向

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

這是我的項目的目錄:

/handshakeapp:
    templates/
    __init__.py
    admin.py
    models.py
    pipelines.py
    views.py
/VKHandshake:
    __init__.py
    settings.py
    urls.py
    ...
manage.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'
)

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

但是,每次我嘗試使用社交身份驗證登錄時,它都會重定向到/accounts/login/ 如果我從SOCIAL_AUTH_PIPELINE中刪除了'handshakeapp.pipelines.fill_extendeduser' ,它'handshakeapp.pipelines.fill_extendeduser'起作用。 怎么了?

問題出在fill_extendeduser函數中。 如@omab所述,它引發了一個異常,並且:

Django auth進程將吃掉異常並重定向到LOGIN_URL的值,默認情況下為/ accounts / login /。 因此,在代碼周圍添加一個try / except塊,以檢查是否引發任何錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM