Closed torgeirl closed 11 months ago
The release notes of Django Allauth v0.55.0 mentions some changes that might be related:
Backwards incompatible changes
- Data model changes: when
ACCOUNT_UNIQUE_EMAIL=True
(the default), there was a unique constraint on set on theEmailAddress
model. This constraint has been relaxed, now there is a unique constraint on the combination ofverified=True
. Migrations are in place to automatically transition, but if you have a lot of accounts, you may need to take special care usingCREATE INDEX CONCURRENTLY
.- The method
allauth.utils.email_address_exists()
has been removed.- (...)
Hopefully solved with dbbd5bd64736447bf628b4a057fa3e9e2237eb44.
It seems many users experience a HTTP 500 error the first time they log in using the federated authentication.
It is caused by an
AssertionError
triggered by attempting to insert their email. It happens whentrix/trix_auth /allauth_adapter.py
'ssave_user
function usesallauth/socialaccount/models.py
'ssave
function which usesallauth/account/utils.py
'ssetup_user_email
. Trace:allauth/account/utils.py
insetup_user_email
at line 266allauth/socialaccount/models.py
insave
at line 253trix/trix_auth/allauth_adapter.py
insave_user
at line 25allauth/socialaccount/helpers.py
in_process_signup
at line 47allauth/socialaccount/helpers.py
in_complete_social_login
at line 181allauth/socialaccount/helpers.py
incomplete_social_login
at line 160allauth/socialaccount/providers/oauth2/views.py
indispatch
at line 158allauth/socialaccount/providers/oauth2/views.py
inview
at line 81django/core/handlers/base.py
in_get_response
at line 181django/core/handlers/exception.py
ininner
at line 47Line 266 in
allauth/account/utils.py
reads:assert not EmailAddress.objects.filter(user=user).exists()
When it yields an exception, the values it receives (among other things) an
user
object (<User: username@uio.no>
) and anaddresses
object ([ <EmailAddress: username@uio.no>]
) whereusername
in both cases is a valid UiO username.It looks to me that
AssertionError
is triggered due to some failed check:SELECT (1) AS "a" FROM "account_emailaddress" WHERE "account_emailaddress"."user_id" = %s LIMIT 1
.For some reason this doesn't happen in our test environment so unclear if we have some unintended differences between test and production, or if its simply «a numbers game».