【问题标题】:Python Social Auth: Not change info for existant user when associating accountPython Social Auth:关联帐户时不更改现有用户的信息
【发布时间】:2015-03-25 20:59:49
【问题描述】:

我的 django 应用程序正在使用 Python Social Auth 向 Fb/G+/Twitter 注册新用户,但我也希望用户能够将他们现有的帐户与 Facebook/Google+/Twitter 相关联。 问题是,每当我将新帐户连接到现有帐户时,使用标准管道会将现有帐户上的所有信息更改为我与之关联的社交帐户上的信息。 例如。: 如果我在我的网站上有一个电子邮件 abc@gmail.com 帐户,但我与之关联的 Facebook 帐户上的电子邮件是 123@gmail.com,它会更改为那个。 我尝试从管道中删除“social.pipeline.user.user_details”,但是当我创建新用户时,它不会将信息从 facebook 拉到帐户中,这是我想要的。

(如何)我可以解决这个问题吗?

谢谢!

【问题讨论】:

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


    【解决方案1】:

    我最后所做的是为管道创建一个新函数,该函数调用现有的populate_info,默认情况下在时间轴中,但前提是它是一个新帐户(由 kwargs 中的 'is_new' 确定):

    from social.pipeline.user import user_details
    
    def populate_info(strategy, details, user=None, *args, **kwargs):
        if (kwargs['is_new']):
            user_details(strategy, details, user, args, kwargs)
    

    在 settings.py 上:

    SOCIAL_AUTH_PIPELINE = (
    
        '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',
        'myapp.auth_pipeline.populate_info',
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-13
      • 1970-01-01
      相关资源
      最近更新 更多