我想为2种不同的用户类型(即消费者用户和供应商用户)创建2种不同的注册机制。使用python-social-auth执行此操作的最简单方法是什么?
为了使讨论更加集中,我们假设有2个注册页面:example.com/consumer-signup
和example.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] 删除。
我来说两句