简体   繁体   中英

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

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 :

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. It works if I remove 'handshakeapp.pipelines.fill_extendeduser' from SOCIAL_AUTH_PIPELINE. What's wrong?

The problem was in fill_extendeduser function. It raised an exception and, as mentioned by @omab:

Django auth process will eat the exceptions and redirect to the value of LOGIN_URL which by default is /accounts/login/. So, add a try/except block around your code to check if it's raising any error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM