【问题标题】:python-social-auth - Update Email Addresspython-social-auth - 更新电子邮件地址
【发布时间】:2014-10-22 07:12:58
【问题描述】:

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

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

【问题讨论】:

    标签: python django-socialauth python-social-auth


    【解决方案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>
    

    这应该可以解决问题。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2015-02-19
        • 1970-01-01
        • 2015-11-08
        • 1970-01-01
        • 1970-01-01
        • 2019-08-10
        • 2019-11-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多