corradio / polynomial

A central place to track your most vital KPIs
https://polynomial.so
9 stars 2 forks source link

Better error message when signing up with social and unable to link #96

Open corradio opened 1 year ago

corradio commented 1 year ago

Links:

Internal Server Error: /accounts/social/signup/

IntegrityError at /accounts/social/signup/ duplicate key value violates unique constraint "account_emailaddress_email_key" DETAIL: Key (email)=(xx@electricitymaps.com) already exists.

Request Method: POST Request URL: https://polynomial.so/accounts/social/signup/ Django Version: 4.1.7 Python Executable: /usr/local/bin/python Python Version: 3.9.16 Python Path: ['/code', '/code', '/usr/local/bin', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/root/.local/lib/python3.9/site-packages', '/usr/local/lib/python3.9/site-packages'] Server time: Wed, 22 Mar 2023 14:57:27 +0000 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_jsonform', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.linkedin_oauth2', 'compressor', 'mainapp'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/allauth/account/utils.py", line 313, in send_email_confirmation email_address = EmailAddress.objects.get_for_user(user, email) File "/usr/local/lib/python3.9/site-packages/allauth/account/managers.py", line 63, in get_for_user raise self.model.DoesNotExist()

During handling of the above exception (), another exception occurred: File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 929, in get_or_create return self.get(**kwargs), False File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 650, in get raise self.model.DoesNotExist(

corradio commented 1 year ago

Note: we can't auto log in as we'd need to verify that the social email address is verified (else someone could be impersonating). This is only possible with Google and is provider dependant.

Update: a new user friendly error is now shown since https://github.com/corradio/polynomial/commit/c12bc3949f976b44a2782482355a9cff51eade44:

image
corradio commented 1 year ago

Action: add a better error message, see https://github.com/pennersr/django-allauth/issues/215#issuecomment-15010643 Depends on #107

Note: we should let the providers define their verified flag on email addresses and avoid overriding it. For example, even if we know LinkedIn addresses are supposed to be verified, it is unclear if the user added a new email that hasn't been verified yet.