I received a ticket that a user cannot log into any of our services because they get an OOPS every time. I checked the logs (OOPS 2092canistelubuntu1424), and it seems that their account has managed to violate a database constraint somehow. The traceback includes:
File "/usr/lib/pymodules/python2.6/django/contrib/auth/__init__.py", line 55, in authenticate
user = backend.authenticate(**credentials)
File "/srv/login.ubuntu.com/production/canonical-identity-provider/identityprovider/auth.py", line 59, in authenticate
account.last_login = datetime.now()
File "/srv/login.ubuntu.com/production/canonical-identity-provider/identityprovider/models/account.py", line 201, in _set_last_login
if self.user is not None:
File "/srv/login.ubuntu.com/production/canonical-identity-provider/identityprovider/models/account.py", line 183, in user
if self.preferredemail:
File "/srv/login.ubuntu.com/production/canonical-identity-provider/identityprovider/models/account.py", line 142, in _get_preferredemail
email.save()
...
IntegrityError: duplicate key value violates unique constraint "emailaddress__person__key"
... why does a login procedure end up calling a line like 'email.save()' ? That seems rather odd.
I guess it could be used to automatically mark which address is preferred, but that seems like a task better done in the session than in long-term storage.