iMerica / dj-rest-auth

Authentication for Django Rest Framework
https://dj-rest-auth.readthedocs.io/en/latest/index.html
MIT License
1.66k stars 308 forks source link

How to replicate RegisterSerializer.custom_signup for social signups #592

Open trackers153 opened 7 months ago

trackers153 commented 7 months ago

Hi - I have posted this question here but am wondering if this might be the better forum for it.

I have overridden RegisterSerializer.custom_signup (REGISTER_SERIALIZER) to set certain parameters in the user's profile based on cookie values and it works fine when a user registers using email/password. However, what I realized was that it's not getting called when the user registers through social (Google, specifically).

I found SocialLoginSerializer.post_signup which sounds like it might be the right place to inject similar logic, but I am not sure how to tell dj_rest_auth to use the overridden class. There does not appear to be an equivalent to the REGISTER_SERIALIZER config variable that points to the new class.

I also considered moving this logic to User's post_save signal event, but unfortunately one can't access the request (and cookies) from there (without some middleware acrobatics).

I am using dj_rest_auth 4.0.1 and allauth 0.50.0

Thanks in advance for any pointers.