0
votes

I am using python-social-auth and my pipeline is as follows:

'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.user.get_username',
'social.pipeline.social_auth.associate_by_email',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',

I want to add a form after get_username where I want to ask the user for his email address. I do not get one from the backend provider. I want to put that email address and associate the account with that email address.

How is this possible? How should the function be?

2

2 Answers

1
votes

The function:

from django.shortcuts import render

from social.pipeline.partial import partial


@partial
def require_email(strategy, backend, details, user=None, is_new=False, *args, **kwargs):
    if is_new and not details.get('email'):
        email = strategy.request_data().get('email')
        if email:
            details['email'] = email
        else:
            return render(strategy.request, 'require_email.html', backend=backend.name)

The template:

<form method="post" action="/complete/{{ backend }}/">{% csrf_token %}
    <label for="email">Email:</label>        
    <input id="email" type="email" placeholder="Your email address">
    <button>Submit</button>
</form>

That should do the trick.

0
votes

I think what you are looking for is described in the email validation are here: http://psa.matiasaguirre.net/docs/pipeline.html#extending-the-pipeline