EMAIL_AUTHENTICATION_AUTO_CONNECT #3627
Replies: 2 comments 6 replies
-
Here is what I did to solve it, lets first see the error, so for the first login the code falls into ret = _process_signup(request, sociallogin)
to pass redirect to signup in def _process_signup(request, sociallogin), I set ACCOUNT_PREVENT_ENUMERATION = "strict" in settings, then I override the save function to prevent create duplicate users in django user db, This is not a good solution but this is the only way I found to cover all cases, `
` it is working, but I dont like it at all! |
Beta Was this translation helpful? Give feedback.
-
Anyone has better solution? |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am facing problem to solve a problem. Here is the scenario, user is created in django users model and on first sso login I want to connect the user, so I added this
`
def pre_social_login(self, request, sociallogin):
if sociallogin.is_existing:
return
`
then I get this error when user try to login,
Object of type AppConfigData is not JSON serializable Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch response = handler(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/dj_rest_auth/views.py", line 125, in post self.serializer.is_valid(raise_exception=True) File "/usr/local/lib/python3.11/site-packages/rest_framework/serializers.py", line 227, in is_valid self._validated_data = self.run_validation(self.initial_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/rest_framework/serializers.py", line 429, in run_validation value = self.validate(value) ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/dj_rest_auth/registration/serializers.py", line 161, in validate ret = complete_social_login(request, login) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/allauth/socialaccount/helpers.py", line 209, in complete_social_login return _complete_social_login(request, sociallogin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/allauth/socialaccount/helpers.py", line 227, in _complete_social_login ret = _process_signup(request, sociallogin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/allauth/socialaccount/helpers.py", line 70, in _process_signup request.session["socialaccount_sociallogin"] = sociallogin.serialize() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/allauth/socialaccount/models.py", line 221, in serialize user=serialize_instance(self.user), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/allauth/socialaccount/adapter.py", line 174, in serialize_instance return serialize_instance(instance) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/allauth/utils.py", line 186, in serialize_instance return json.loads(json.dumps(data, cls=DjangoJSONEncoder)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/init.py", line 238, in dumps **kw).encode(obj) ^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/encoder.py", line 200, in encode chunks = self.iterencode(o, _one_shot=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/encoder.py", line 258, in iterencode return _iterencode(o, 0) ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/django/core/serializers/json.py", line 106, in default return super().default(o) ^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/json/encoder.py", line 180, in default raise TypeError(f'Object of type {o.class.name} ' TypeError: Object of type AppConfigData is not JSON serializable
So I trace back the code and I found EMAIL_AUTHENTICATION_AUTO_CONNECT, and I set that, but I am still getting the same error.
I am filling I am missing what is happening through connect, because if I remove the created user in db and go through sso process it is working but when user is created in advance it is failing to login and connect as I paste the error.
Would appreciate your help.
Yashar.
Beta Was this translation helpful? Give feedback.
All reactions