Confirming an email address throws an unexpected error when already confirmed via Persona

Bug #1057176 reported by François Marier
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Libravatar (obsolete)
Fix Released
Medium
François Marier

Bug Description

When a user clicks a confirmation link for an email that has already been confirmed using Persona, an error page is displayed due to a database uniqueness constraint violation:

  File "/usr/share/libravatar/libravatar/account/views.py", line 93, in confirm_email
    not request.user.is_anonymous())

  File "/usr/share/libravatar/libravatar/account/models.py", line 243, in create_confirmed_email
    confirmed.save()

  IntegrityError: ERREUR: la valeur d'une clé dupliquée rompt la contrainte unique « account_confirmedemail_email_key »

Steps to reproduce:

1- create a new username+password account
2- add a new email address manually (but don't check your emails yet)
3- add a new email address but this time, use Persona to add the same one
4- go back to the profile page to see that email address both under "confirmed" and "unconfirmed" emails
5- click on the link sent in the confirmation email

summary: - Confirming an email address fail when already confirmed via Persona
+ Confirming an email address throws an unexpected error when already
+ confirmed via Persona
Revision history for this message
François Marier (fmarier) wrote :

Three things to fix:

1. the unconfirmed email should be deleted before we attempt to confirm the email to ensure that any bugs further down the function don't leave unconfirmed emails around
2. before creating a confirmed email object, check that it's not already confirmed. if it is, display an appropriate error message
3. confirming an email using Persona should delete any matching unconfirmed emails that a user has in their account

Changed in libravatar:
status: Confirmed → In Progress
Revision history for this message
François Marier (fmarier) wrote :

Deleting the unconfirmed email is tricky so I've skipped that. Otherwise, it's fixed on master.

Changed in libravatar:
status: In Progress → Fix Committed
Changed in libravatar:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.