Fix: #1102 Remove IntegrityError when using a released email to register #1176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes in this pull request
Fixes #1102
Bug Description: Registering with an email that is no longer associated with an account throws an error.
Cause: When a new user registers, an EmailAddress (Model class in allauth.account.models) object is created and an email confirmation mail is sent. When the same user updates his/her email in the profile, the EmailAddress object associated with his User model was not being deleted which caused IntegrityError.
Solution: In clean_email method of ProfileForm class, delete any old instances of EmailAddress model for the current user if email is being updated.
When should this PR be merged
PR can be merged without any preconditions.
Risks
There are no risks from merging this pull request.
Follow up actions
No extra actions required.
Checklist (for reviewing)
General
migration
label if a new migration is added.Functionality
Code
Tests
Documentation