dj-rest-auth
dj-rest-auth copied to clipboard
allauth_settings USER_MODEL_EMAIL_FIELD not taken into consideration
I am implementing dj-rest-auth to only add social log-in to my rest framework and my User model has an email field that has different name than "email". Therefore I set the USER_MODEL_EMAIL_FIELD but this is not taken into consideration in the serializers.
When trying to do social login of an account that already exists signed by email the code breaks. I made a quick fix changing this part by this:
email = getattr(login.user, allauth_settings.USER_MODEL_EMAIL_FIELD)
email_search = {allauth_settings.USER_MODEL_EMAIL_FIELD: email}
account_exists = get_user_model().objects.filter(**email_search).exists()
This probably should have a bigger effect in the repo and that is why I haven't done a pull request for it