For last few days, I was working on implementing a feature where the users who log in through the social log in methods in Transifex can choose a username, when logging in for the first time. Logically, I had to add in a step in the transifex social_auth_pipeline to display the user with a form to enter the desired username, before the user is created. django-social-auth provides us with Partial Pipeline where one can halt the pipeline process and ask the user for more data, and then resume. As mentioned in the docs:
It’s possible to cut the pipeline process to return to the user asking for more data and resume the process later, to accomplish this add the entry social_auth.backends.pipeline.misc.save_status_to_session (or a similar implementation) to the pipeline setting before any entry that returns an HttpResponse instance
The example below can be used implement partial pipeline
SOCIAL_AUTH_PIPELINE = (
...
social_auth.backends.pipeline.misc.save_status_to_session,
app.pipeline.redirect_to_basic_user_data_form
...
)
After the pipeline resumes, by default the pipeline is resumed from the next entry after save_status_to_session but this can be modified by setting the following setting to the import path of the pipeline entry to resume processing
SOCIAL_AUTH_PIPELINE_RESUME_ENTRY = 'social_auth.backends.pipeline.misc.save_status_to_session'
This comes handy when the user inputs an invalid/duplicate data and one need to cut the pipeline process again. After implementing this feature, I submitted the patch to upstream and hope to get it accepted.
REFERENCE: http://django-social-auth.readthedocs.org/en/latest/pipeline.html
Like this:
Like Loading...