Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] AllAuth inconsistent email data with social logins #714

Open
alp-tekinalp opened this issue Jul 25, 2024 · 0 comments
Open

[BUG] AllAuth inconsistent email data with social logins #714

alp-tekinalp opened this issue Jul 25, 2024 · 0 comments
Labels

Comments

@alp-tekinalp
Copy link

alp-tekinalp commented Jul 25, 2024

Tag/version of Container Images
0.4.1-0.5.0

Alternate email addresses causing exception where user_id is duplicated in account_emailaddress table. Noticed when migrating from 0.4.1 to 0.5.0. See traceback below:

  File "/usr/lib/python3.11/site-packages/django_mailman3/lib/auth/fedora/views.py", line 56, in get
    return self.post(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django_mailman3/lib/auth/fedora/views.py", line 67, in post
    client = _openid_consumer(
             ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/socialaccount/providers/openid/views.py", line 26, in _openid_consumer
    server_settings = provider.get_server_settings(endpoint)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: OpenIDProvider.get_server_settings() missing 1 required positional argument: 'endpoint'
ERROR 2024-07-25 17:30:08,108 7025 django.request Internal Server Error: /accounts/login/
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/views/decorators/debug.py", line 92, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/views.py", line 156, in dispatch
    return super(LoginView, self).dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/views.py", line 83, in dispatch
    response = super(RedirectAuthenticatedUserMixin, self).dispatch(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/views.py", line 111, in post
    response = self.form_valid(form)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/views.py", line 169, in form_valid
    return form.login(self.request, redirect_url=success_url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/forms.py", line 196, in login
    ret = perform_login(
          ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/utils.py", line 168, in perform_login
    return _perform_login(request, login)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/utils.py", line 178, in _perform_login
    response = adapter.pre_login(request, login.user, **hook_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/adapter.py", line 413, in pre_login
    if not has_verified_email(user, email):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/utils.py", line 135, in has_verified_email
    emailaddress = EmailAddress.objects.get_for_user(user, email)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/allauth/account/managers.py", line 91, in get_for_user
    ret = self.get(user=user, email__iexact=email)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/django/db/models/query.py", line 653, in get
    raise self.model.MultipleObjectsReturned(
allauth.account.models.EmailAddress.MultipleObjectsReturned: get() returned more than one EmailAddress -- it returned 2!

image

We had to drop the duplicate email addresses manually in order to get the container back up. Not sure if there should be an albemic migration for the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant