Reputation: 4135
I want to create 2 different signup mechanisms for 2 different user types, i.e., consumer users and vendor users. What is the simplest way to do this with python-social-auth?
To focus the discussion, let's say that there are 2 signup pages: example.com/consumer-signup
and example.com/vendor-signup
. This question boils down to how I can pass a value from each page to the social auth pipeline or to an authenticator like facebook so that I can retrieve that same value after authentication is complete.
Thanks
Upvotes: 0
Views: 363
Reputation: 8981
You'll likely want to use SOCIAL_AUTH_FIELDS_STORED_IN_SESSION to configure query parameters you can pass into your socialauth_begin
endpoint. You can then retrieve this value in your SOCIAL_AUTH_PIPELINE
and access the request.session for this value.
Something like:
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':
...
Upvotes: 3