如何使用python-social-auth为多种类型的用户实施注册?

lastoneisbearfood

我想为2种不同的用户类型(即消费者用户和供应商用户)创建2种不同的注册机制。使用python-social-auth执行此操作的最简单方法是什么?

为了使讨论更加集中,我们假设有2个注册页面:example.com/consumer-signupexample.com/vendor-signup这个问题归结为如何将每个页面的值传递给社交身份验证管道或Facebook之类的身份验证器,以便身份验证完成后我可以检索相同的值。

谢谢

凯文·斯通

您可能需要使用SOCIAL_AUTH_FIELDS_STORED_IN_SESSION配置可以传递到socialauth_begin端点的查询参数然后,您可以在自己的服务器中检索此值,SOCIAL_AUTH_PIPELINE并访问该值的request.session。

就像是:

您的设定

SOCIAL_AUTH_FIELDS_STORED_IN_SESSION = ('user_type', )

您的登录模板

a href="{% url socialauth_begin '[backend]' %}?user_type=vendor">Sign-in as Vendor</a>

您的管道阶段

def set_user_type(strategy, details, response, user=None, is_new=False, *args, **kwargs):
    user_type = strategy.session.get('user_type')
    if user_type == 'vendor':
        ...

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何使用类型提示为参数指定多种类型?

如何将Django OAuth Toolkit与Python Social Auth结合使用?

如何测试自定义的python-social-auth管道?

如何使用python-social-auth通过代码中的访问令牌进行身份验证

用于注册/登录用户的Django REST Framework和python-social-auth

Django的。Python Social Auth获取用户后端

Django的python-social-auth:ImportError:没有名为“ social_django”的模块

Django的Python Social Auth引发Authforbidden异常

集成python-social-auth(social-app-django)以与Django admin一起使用

如何在Django REST Social Auth中使用Angular 5?

Django的Python Social Auth-如何检索额外数据?

如何从python-social-auth获取用户的生日

对多种用户类型使用django-rest-auth注册

如何使用Unity按名称注册多种类型?

如何使用python social auth实现facebook身份验证?

Python Social Auth获取Google头像

在Linkedin上使用python-social-auth

使用django social-auth访问用户当前的公司

如何允许参数为多种类型?

使用python-social-auth在数据库中预注册用户

将Python Social Auth用户名传递给View

如何解决python-social-auth错误?

如何使用python-social-auth在Django APP上注销Facebook本身?

“ python-social-auth”或“ django-social-auth”

如何使用social-auth-app-django刷新令牌?

python-social-auth Facebook 和 LinkedIn 用户的电子邮件为空

Python social-auth-app-django 'social' 不是注册的命名空间

python social auth twitter 403后跟220

Python Social Auth Django 安装失败