pythonsocialauth更新电子邮件地址

2024-05-16 20:57:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用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后面添加一个表单,在那里我要询问用户的电子邮件地址。我没有从后端提供商那里得到一个。我想将该电子邮件地址与该电子邮件地址相关联。

这怎么可能?功能应该是怎样的?在


Tags: authuidgetby管道pipeline电子邮件email
2条回答

我想您需要的是电子邮件验证中描述的内容: http://psa.matiasaguirre.net/docs/pipeline.html#extending-the-pipeline

功能:

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)

模板:

^{pr2}$

这应该能解决问题。在

相关问题 更多 >