Ast*_*isk 9 python django single-sign-on django-socialauth
我正在使用django social-auth(http://django-social-auth.readthedocs.org/en/latest/index.html)并尝试创建一个用户配置文件,用户可以在其中关联多个帐户(如此处在Stackoverflow上) .
目前,我正处于单个用户可以使用不同身份验证提供程序登录的位置,但是对于每个登录,都会创建一个新用户.如何将所有用户帐户关联到单个帐户(如用户配置文件)?
此外,使用django social-auth时创建用户个人资料页面的最佳做法是什么?
oma*_*mab 11
DSA已经支持多个帐户关联,其诀窍在于用户必须登录,否则DSA不知道它应该与现有帐户相关联.
关于您的个人资料,向DSA添加功能的推荐方法是扩展管道,您可以创建如下条目:
def create_profile(user, is_new=False, *args, **kwargs):
if is_new:
# create a profile instance for the given user
create_user_profile(user)
Run Code Online (Sandbox Code Playgroud)
然后在如下设置中注册:
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
'myapp.pipeline.create_profile'
)
Run Code Online (Sandbox Code Playgroud)
条目是获取该功能的导入路径.
编辑:链接到文档和设置说明.
| 归档时间: |
|
| 查看次数: |
4884 次 |
| 最近记录: |