0

我正在使用python-social-auth ,我的管道如下:

'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',

get_username我想在向用户询问他的电子邮件地址之后添加一个表单。我没有从后端提供商那里得到一个。我想输入该电子邮件地址并将该帐户与该电子邮件地址相关联。

这怎么可能?功能应该如何?

4

2 回答 2

1

功能:

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)

模板:

<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>

这应该够了吧。

于 2014-10-22T12:44:41.717 回答
0

我认为您在电子邮件验证中描述了您正在寻找的内容:http: //psa.matiasaguirre.net/docs/pipeline.html#extending-the-pipeline

于 2014-11-14T03:56:34.363 回答